@nomad-e/bluma-cli 0.0.38 → 0.0.40

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 (4) hide show
  1. package/LICENSE +75 -9
  2. package/README.md +293 -5
  3. package/dist/main.js +181 -25
  4. package/package.json +1 -1
package/LICENSE CHANGED
@@ -4,14 +4,80 @@ http://www.apache.org/licenses/
4
4
 
5
5
  Copyright 2025 Alex Fonseca and NomadEngenuity contributors
6
6
 
7
- Licensed under the Apache License, Version 2.0 (the "License");
8
- you may not use this file except in compliance with the License.
9
- You may obtain a copy of the License at
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10
8
 
11
- http://www.apache.org/licenses/LICENSE-2.0
9
+ 1. Definitions.
12
10
 
13
- Unless required by applicable law or agreed to in writing, software
14
- distributed under the License is distributed on an "AS IS" BASIS,
15
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- See the License for the specific language governing permissions and
17
- limitations under the License.
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License.
32
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
33
+
34
+ 3. Grant of Patent License.
35
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36
+
37
+ 4. Redistribution.
38
+ You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
39
+
40
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
41
+
42
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
43
+
44
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
45
+
46
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
47
+
48
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
49
+
50
+ 5. Submission of Contributions.
51
+ Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
52
+
53
+ 6. Trademarks.
54
+ This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
55
+
56
+ 7. Disclaimer of Warranty.
57
+ Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
58
+
59
+ 8. Limitation of Liability.
60
+ In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
61
+
62
+ 9. Accepting Warranty or Additional Liability.
63
+ While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
64
+
65
+ END OF TERMS AND CONDITIONS
66
+
67
+ APPENDIX: How to apply the Apache License to your work.
68
+
69
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
70
+
71
+ Copyright 2025 Alex Fonseca and NomadEngenuity contributors
72
+
73
+ Licensed under the Apache License, Version 2.0 (the "License");
74
+ you may not use this file except in compliance with the License.
75
+ You may obtain a copy of the License at
76
+
77
+ http://www.apache.org/licenses/LICENSE-2.0
78
+
79
+ Unless required by applicable law or agreed to in writing, software
80
+ distributed under the License is distributed on an "AS IS" BASIS,
81
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82
+ See the License for the specific language governing permissions and
83
+ limitations under the License.
package/README.md CHANGED
@@ -16,19 +16,24 @@ BluMa CLI is an independent agent for automation and advanced software engineeri
16
16
  - [Overview](#overview)
17
17
  - [Key Features](#key-features)
18
18
  - [Requirements](#requirements)
19
+ - [Architecture Diagram](#-architecture-diagram)
19
20
  - [Installation](#installation)
20
- - [How to Run](#how-to-run)
21
- - [Project Structure](#project-structure)
21
+ - [Usage](#usage)
22
+ - [Examples](#-usage-examples)
23
+ - [Configuration and Environment Variables](#configuration-and-environment-variables)
22
24
  - [Development and Build](#development-and-build)
23
25
  - [Extensibility: Tools and Plugins](#extensibility-tools-and-plugins)
24
26
  - [Tests](#tests)
25
- - [Configuration and Environment Variables](#configuration-and-environment-variables)
27
+ - [Limitations / Next Steps](#️-limitations--next-steps)
28
+ - [Security Notes](#-security-notes)
29
+ - [Tech Stack Overview](#stack)
30
+ - [Contributing](#-contributing)
26
31
  - [License](#license)
27
32
 
28
33
  ---
29
34
 
30
35
  ## <a name="overview"></a>Overview
31
- BluMa CLI is a modern CLI focused on automation, LLM collaboration, documentation, refactoring, running complex tasks, and integrating with external tools. It uses React (via Ink) for rich terminal interfaces and features context/conversation management, smart feedback, and interactive confirmation systems.
36
+ BluMa CLI is a modular conversational agent and task automation framework focused on advanced software engineering workflows. It runs entirely in the terminal using React (via Ink) for a rich interactive UI, and is architected around a **UI layer** (`main.ts` + `App.tsx`) and an **agent layer** (`Agent` orchestrator + `BluMaAgent` core). It enables LLM-powered automation, documentation, refactoring, running complex development tasks, and integrating with both native and external tools. The system features persistent sessions, contextual reasoning, smart feedback, and an interactive confirmation system for controlled execution.
32
37
 
33
38
  ---
34
39
 
@@ -266,4 +271,287 @@ Advanced config files are located in `src/app/agent/config/`.
266
271
  ## <a name="license"></a>License
267
272
  Apache-2.0. Made by Alex Fonseca and NomadEngenuity contributors.
268
273
 
269
- Enjoy, hack, and—if possible—contribute!
274
+ Enjoy, hack, and—if possible—contribute!
275
+
276
+ ---
277
+
278
+ ## 🏗 Architecture Diagram
279
+ Below is a simplified diagram showing BluMa CLI's core architecture:
280
+ ```
281
+ [ main.ts ] → [ App.tsx (UI Layer) ]
282
+
283
+ [ Agent (Orchestrator) ]
284
+
285
+ [ BluMaAgent (Core Loop & State) ]
286
+
287
+ [ MCPClient / Tools / Native Tools / SubAgents ]
288
+
289
+ [ External APIs & System Operations ]
290
+ ```
291
+ This flow ensures a clean separation between presentation, orchestration, core logic, and integration layers.
292
+
293
+ ### Sequence Diagram
294
+ ```mermaid
295
+ sequenceDiagram
296
+ participant UI as UI (main.ts + App.tsx)
297
+ participant Agent as Agent (Orchestrator)
298
+ participant Core as BluMaAgent (Core Loop)
299
+ participant MCP as MCPClient / Tools
300
+
301
+ UI->>Agent: Initialize(sessionId, eventBus)
302
+ Agent->>Core: initialize()
303
+ Core->>MCP: initialize tools
304
+ UI->>Agent: processTurn(userInput)
305
+ Agent->>Core: processTurn(content)
306
+ Core->>MCP: Get available tools & context
307
+ MCP-->>Core: Tool list & details
308
+ Core-->>Agent: Tool call request or LLM message
309
+ Agent-->>UI: backend_message (e.g., confirmation_request)
310
+ UI->>Agent: handleToolResponse()
311
+ Agent->>Core: handleToolResponse(decision)
312
+ Core->>MCP: Execute tool
313
+ MCP-->>Core: Tool result
314
+ Core-->>Agent: backend_message(done)
315
+ Agent-->>UI: Update history & UI state
316
+ ```
317
+
318
+ ---
319
+
320
+ ### Component Diagram
321
+ ```mermaid
322
+ flowchart TD
323
+ subgraph UI["UI Layer"]
324
+ M["main.ts"]
325
+ A["App.tsx"]
326
+ end
327
+ subgraph AG["Agent Layer"]
328
+ AGN["Agent (Orchestrator)"]
329
+ CORE["BluMaAgent (Core Loop)"]
330
+ end
331
+ subgraph TOOLS["Tools & Integration"]
332
+ MCP["MCPClient"]
333
+ NT["Native Tools"]
334
+ SA["SubAgents"]
335
+ end
336
+ EXT["External APIs & FS"]
337
+
338
+ M --> A --> AGN --> CORE --> MCP --> NT
339
+ CORE --> SA
340
+ MCP --> EXT
341
+ NT --> EXT
342
+ ```
343
+
344
+ ---
345
+
346
+ ### Activity Diagram
347
+ ```mermaid
348
+ flowchart TD
349
+ Start((Start)) --> Input[User Input in UI]
350
+ Input --> Processing{Command Type?}
351
+ Processing -->|Slash Command| SC[Handle Slash Command]
352
+ Processing -->|Normal Input| PT[processTurn]
353
+ SC --> Done((End))
354
+ PT --> LLM[Send to LLM]
355
+ LLM --> ToolCall{Tool Requested?}
356
+ ToolCall -->|No| Display[Display Assistant Message]
357
+ ToolCall -->|Yes| Confirm[Ask for Confirmation]
358
+ Confirm --> Decision{Decision}
359
+ Decision -->|Accept| Exec[Execute Tool]
360
+ Decision -->|Decline| Skip[Skip Execution]
361
+ Exec --> Result[Return Tool Result]
362
+ Skip --> Done
363
+ Result --> Done
364
+ Display --> Done
365
+ ```
366
+
367
+ ---
368
+
369
+ ### State Machine Diagram
370
+ ```mermaid
371
+ stateDiagram-v2
372
+ [*] --> Idle
373
+ Idle --> Processing: User Input
374
+ Processing --> Awaiting_Confirmation: Tool Call Needs Approval
375
+ Awaiting_Confirmation --> Processing: User Accepts
376
+ Awaiting_Confirmation --> Idle: User Declines
377
+ Processing --> Completed: Task Completed
378
+ Processing --> Interrupted: User Interrupt
379
+ Completed --> Idle
380
+ Interrupted --> Idle
381
+ ```
382
+
383
+ ---
384
+
385
+ ### Deployment Diagram
386
+ ```mermaid
387
+ graph TD
388
+ CLI["CLI (BluMa)"] --> LocalFS[("Local File System")]
389
+ CLI --> AzureOpenAI[("Azure OpenAI API")]
390
+ CLI --> GitHubAPI[("GitHub API")]
391
+ CLI --> NotionAPI[("Notion API")]
392
+ CLI --> OtherAPIs[("Other External APIs")]
393
+ CLI --> MCPServer[("MCP Server / Plugins")]
394
+ ```
395
+
396
+ ---
397
+
398
+ ### Data Flow Diagram
399
+ ```mermaid
400
+ flowchart LR
401
+ U[User] --> UI[UI Layer]
402
+ UI --> Agent[Agent]
403
+ Agent --> Core[BluMaAgent]
404
+ Core --> MCP[MCPClient]
405
+ Core --> Sub[SubAgents]
406
+ MCP --> Tools[Native Tools & External APIs]
407
+ Sub --> Tools
408
+ Tools --> MCP
409
+ MCP --> Core
410
+ Core --> Agent
411
+ Agent --> UI
412
+ UI --> U
413
+ ```
414
+
415
+ ---
416
+
417
+ ## 💡 Usage Examples
418
+ - **Run Initialization Command**
419
+ ```
420
+ /init
421
+ ```
422
+ Executes the `init` subagent to prepare the working environment.
423
+
424
+ - **Confirm an Edit Operation**
425
+ When the system prompts an `edit_tool` operation, review the preview and choose:
426
+ ```
427
+ Accept | Decline | Accept Always
428
+ ```
429
+
430
+ - **Live Overlay**
431
+ During a long-running task, you can send hints:
432
+ ```
433
+ [hint] Prefer small batch edits
434
+ [constraint] Avoid editing src/app/ui/**
435
+ ```
436
+
437
+ ---
438
+
439
+ ## 🤝 Contributing
440
+ We welcome contributions! For full details, read [CONTRIBUTING.md](CONTRIBUTING.md).
441
+
442
+ ### 📋 Prerequisites
443
+ - **Node.js** >= 18 and **npm** >= 9 installed
444
+ - Dependencies installed via `npm install`
445
+ - Required environment variables configured (see *Configuration* section)
446
+
447
+ ### 🔄 Contribution Workflow
448
+ 1. **Fork** the repository
449
+ 2. **Clone** your fork locally
450
+ 3. Create a feature branch named according to [Conventional Commits](https://www.conventionalcommits.org/) (e.g., `feat/add-logging`)
451
+ 4. Commit changes with meaningful messages
452
+ 5. Push to your fork and open a Pull Request
453
+
454
+ ### 🛠 Code Standards
455
+ - Follow TypeScript strict mode guidelines
456
+ - Maintain style via ESLint and Prettier (`npm run lint`)
457
+ - Keep functions short, modular, and documented with JSDoc
458
+ - All business logic must have unit tests
459
+
460
+ ### 🧪 Testing Requirements
461
+ - Run `npm test` and ensure all tests pass
462
+ - Include new tests for any new functionality or bug fix
463
+ - Validate integration tests when adding new tools or APIs
464
+
465
+ ### 🔍 Code Review Process
466
+ - Minimum of 1 maintainer approval before merge
467
+ - Resolve all review comments and passing CI before merge
468
+
469
+ ### 📄 Documentation
470
+ - Update README.md or relevant Wiki pages when adding/removing features
471
+ - Add or update CHANGELOG.md for notable changes
472
+
473
+ ---
474
+
475
+ ## ⚠️ Limitations / Next Steps
476
+ - Current LLM integration optimised for Azure OpenAI; add more providers.
477
+ - Logging verbosity could be made configurable.
478
+ - Potential for richer plugin lifecycle (install/remove at runtime).
479
+ - Improve error reporting in subagents.
480
+
481
+ ---
482
+
483
+ ## 🔒 Security Notes
484
+
485
+ ---
486
+
487
+ ## 🛠 Error Handling & Recovery Flows
488
+ BluMa handles different classes of errors gracefully:
489
+ - **Network/API Errors**: Retry logic with exponential backoff.
490
+ - **Authentication Failures**: Immediate notification to user, requires updating environment variables.
491
+ - **Tool Execution Errors**: Displayed with detailed message; execution can be retried or skipped.
492
+ - **LLM/API Exceptions**: Fall back to safe mode and keep context intact.
493
+ - **Session/History Save Failures**: Warn user and continue without losing core functionality.
494
+
495
+ ---
496
+
497
+ ## 📈 Metrics & Observability
498
+ - **Performance Metrics**: Average response time, tokens used per request, tool execution times.
499
+ - **Usage Tracking**: Number of commands executed, tool calls, sessions created.
500
+ - **Logging**: Structured logs for all events.
501
+ - Integration-ready with Prometheus/Grafana or external observability platforms.
502
+
503
+ ---
504
+
505
+ ## 🔐 Advanced Security Practices
506
+ - Use secret management tools (Vault, AWS Secrets Manager) to store environment variables.
507
+ - Apply principle of least privilege for API keys.
508
+ - Validate and sanitize all user inputs to avoid prompt injection attacks.
509
+ - Regularly rotate API keys.
510
+
511
+ ---
512
+
513
+ ## 🚀 Performance & Scalability
514
+ - Optimize context window by pruning irrelevant history.
515
+ - Batch related operations to reduce LLM calls.
516
+ - Support for distributed execution or remote agent hosting.
517
+ - Cache static responses where possible.
518
+
519
+ ---
520
+
521
+ ## 🔄 Development Cycle & CI/CD
522
+ - **Testing**: `npm test` and `npm run test:watch` for development.
523
+ - **Linting**: Enforce coding standards with ESLint/Prettier.
524
+ - **CI/CD**: Recommended GitHub Actions or similar to run tests/build on push.
525
+ - **Deployment**: Automatic packaging to npm or internal registry.
526
+
527
+ ---
528
+
529
+ ## 🗺 Roadmap & Release Notes
530
+ **Upcoming:**
531
+ - Multi-LLM provider support.
532
+ - Web-based dashboard.
533
+ - Richer subagent plugin APIs.
534
+
535
+ **Release Notes**:
536
+ - Follow [CHANGELOG.md](CHANGELOG.md) for version history.
537
+
538
+ ---
539
+
540
+ ## 🎯 Advanced Use Cases
541
+ - Chain multiple tools with complex decision-making.
542
+ - Build custom subagents for domain-specific automation.
543
+ - Integrate with CI pipelines for automated code review and refactoring.
544
+
545
+ ---
546
+
547
+ ## 📏 Code Standards & Contribution Guidelines
548
+ - Follow TypeScript strict mode.
549
+ - Commit messages must follow Conventional Commits (`feat:`, `fix:`, `chore:`).
550
+ - Keep functions short, modular and documented.
551
+ - Add unit tests for all business logic.
552
+
553
+ ---
554
+ - Protect your API keys: never commit `.env` files.
555
+ - `edit_tool` can modify files — review previews before accepting.
556
+ - Use restricted permissions for API tokens wherever possible.
557
+ - If using on shared systems, ensure `.bluma-cli` config is private.
package/dist/main.js CHANGED
@@ -850,7 +850,7 @@ var ConfirmationPrompt = ({ toolCalls, preview, onDecision }) => {
850
850
  // src/app/agent/agent.ts
851
851
  import OpenAI from "openai";
852
852
  import * as dotenv from "dotenv";
853
- import path9 from "path";
853
+ import path10 from "path";
854
854
  import os7 from "os";
855
855
 
856
856
  // src/app/agent/tool_invoker.ts
@@ -1488,7 +1488,7 @@ var AdvancedFeedbackSystem = class {
1488
1488
  };
1489
1489
 
1490
1490
  // src/app/agent/bluma/core/bluma.ts
1491
- import path8 from "path";
1491
+ import path9 from "path";
1492
1492
 
1493
1493
  // src/app/agent/session_manger/session_manager.ts
1494
1494
  import path7 from "path";
@@ -1624,12 +1624,17 @@ async function saveSessionHistory(sessionFile, history) {
1624
1624
 
1625
1625
  // src/app/agent/core/prompt/prompt_builder.ts
1626
1626
  import os5 from "os";
1627
+ import fs9 from "fs";
1628
+ import path8 from "path";
1627
1629
  var SYSTEM_PROMPT = `
1628
- ### IDENTITY AND OBJECTIVE
1629
- You are BluMa, a fully **AUTONOMOUS** AI Software Engineer from NomadEngenuity.
1630
- Your single objective is to complete the user's request from end-to-end.
1631
- You operate with maximum precision, efficiency, and autonomy.
1632
- Use a proprietary Large Language Model fine-tuned for programming and software engineering, optimized for code analysis, generation, and review.
1630
+
1631
+ **Goal:** Operate as a fully autonomous AI software engineer capable of managing end-to-end software development and maintenance tasks \u2014 including coding, refactoring, testing, documentation, environment setup, and repository management \u2014 with no human intervention required unless explicitly requested.
1632
+
1633
+ You are BluMa, a fully AUTONOMOUS AI Software Engineer from NomadEngenuity.
1634
+ Your sole objective is to complete the user's request from end to end, with maximum precision, efficiency, and autonomy.
1635
+ You operate as a CLI agent with full permission to create, modify, delete files, and execute system commands including Git and shell commands.
1636
+ You use a proprietary Large Language Model fine-tuned specifically for programming and software engineering, optimized for code analysis, generation, and review.
1637
+ You are an interactive CLI agent specializing in software engineering tasks. REMEMBER Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
1633
1638
  ---
1634
1639
 
1635
1640
  ### CORE DIRECTIVES
@@ -1643,6 +1648,16 @@ Use a proprietary Large Language Model fine-tuned for programming and software e
1643
1648
 
1644
1649
  ---
1645
1650
 
1651
+ ## Software Engineering Tasks
1652
+ When asked to perform tasks such as fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
1653
+ 1. **Understand:** Think about the user's request and the relevant context of the codebase. Use 'count_file_lines' and 'read_file_lines' to understand the context and validate any assumptions you may have.
1654
+ 2. **Plan:** Develop a coherent and reasoned plan (based on the understanding from step 1) for how you want to solve the user's task. As part of the plan, you should try to use a self-checking loop by writing unit tests, if relevant to the task. Use output logs or debug statements as part of this self-checking cycle to arrive at a solution.
1655
+ 3. **Implement:** Use the tools available to act on the plan, strictly following the conventions established by the project (detailed in 'Core Mandates').
1656
+ 4. Verify (Tests): If applicable and feasible, verify changes using the project's testing procedures. Identify the correct test commands and frameworks by examining the README or BluMa.md files, the build/package configuration (e.g., package.json), or existing test execution standards. NEVER assume standard test commands.
1657
+ 5. Verify (Standards): VERY IMPORTANT: After making code changes, run the project-specific build, linting, and type-checking commands (e.g., tsc, npm run lint, ruff check) that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards. If you are unsure about these commands, you can ask the user if they would like you to run them and, if so, how.
1658
+
1659
+ ---
1660
+
1646
1661
  ### CURRENT ENVIRONMENT CONTEXT
1647
1662
  <current_system_environment>
1648
1663
  - Operating System: {os_type} ({os_version})
@@ -1653,6 +1668,54 @@ Use a proprietary Large Language Model fine-tuned for programming and software e
1653
1668
  - Current Date: {current_date}
1654
1669
  </current_system_environment>
1655
1670
 
1671
+ ---
1672
+
1673
+ <agent_turn>
1674
+
1675
+ 1. RECEIVE TASK AND SEND INITIAL MESSAGE
1676
+ - As soon as you receive the user task, IMMEDIATELY send a confirmation message in an informal but technical style.
1677
+ - Example: "Got your task, I'll start analyzing and working on it right away."
1678
+ - This message officially starts the turn, with no external interruptions allowed.
1679
+
1680
+ 2. OPEN AND USE THE REASONING NOTEBOOK
1681
+ - Open and use the reasoning notebook according to the rules defined in \`<reasoning_rules>\`.
1682
+ - Organize your entire reasoning and planning there.
1683
+
1684
+ 3. USE THE DYNAMIC AND REFLECTIVE PROBLEM-SOLVING TOOL
1685
+ - Break down the task into **remaining_tasks** following this tool's guidelines.
1686
+ - Use the **thought** field for detailed analysis, revisions, and reasoning.
1687
+ - Keep the **remaining_tasks** checklist updated with the mandatory format (\u{1F5F9} done, \u2610 pending).
1688
+ - Adjust total thoughts count as needed.
1689
+ - Explore hypotheses, verify them via chain-of-thought, and recommend appropriate tools for each step.
1690
+ - Never put future steps or to-do items inside **thought**, only in **remaining_tasks**.
1691
+
1692
+ 4. PROCESS REMAINING TASKS
1693
+ - Execute the pending tasks from the **remaining_tasks** checklist one by one, updating the list and reasoning.
1694
+ - Use recommended tools as per the reflective analysis.
1695
+ - Do not finalize or deliver a final answer before completing all pending tasks.
1696
+
1697
+ 5. CLOSE THE TASK AND THE TURN
1698
+ - When all **remaining_tasks** are done, notify the user clearly:
1699
+ "Task completed. There are no further pending actions."
1700
+ - You MUST call the \`<agent_end_task_rules>\` tool to close the turn.
1701
+ - Do not perform any action after calling this tool in the same turn.
1702
+
1703
+ 6. WAIT FOR NEW TASK
1704
+ - After closing the turn, wait for the next task to start a new turn.
1705
+ </agent_turn>
1706
+
1707
+ ---
1708
+
1709
+ ### IMPORTANT RULES
1710
+ - Sending the initial message is mandatory and marks the turn start.
1711
+ - Using the reasoning notebook is mandatory.
1712
+ - Breaking the task into **remaining_tasks** with the reflective problem-solving tool is mandatory.
1713
+ - Never include future steps in the **thought** field, only in the **remaining_tasks** checklist.
1714
+ - Calling \`<agent_end_task_rules>\` is mandatory to close the turn.
1715
+ - Decline out-of-scope tasks professionally before calling \`<agent_end_task_rules>\`.
1716
+ - Process only one task per turn, never multiple concurrently.
1717
+
1718
+
1656
1719
  ---
1657
1720
 
1658
1721
  ### TOOL-SPECIFIC RULES
@@ -1664,6 +1727,60 @@ Use a proprietary Large Language Model fine-tuned for programming and software e
1664
1727
  - Actively use notify for progress updates
1665
1728
  </message_rules>
1666
1729
 
1730
+ ---
1731
+
1732
+ The agent MUST ALWAYS use the prompt below called \`<reasoning_rules>\` to guide all their thinking and execution. This prompt sets clear rules for the use of their \u201Cmental laptop\u201D (called **reasoning_notebook**), which serves as their organized brain and the center of their reasoning.
1733
+
1734
+ ---
1735
+
1736
+ <reasoning_rules>
1737
+ # YOUR THINKING ON A NOTEBOOK - MANDATORY USE
1738
+ CRITICAL: Your laptop (**reasoning_nootebook**) is your ORGANIZED MIND
1739
+ ## IMPORTANT
1740
+ ## NEVER PUT CHECKLISTS OR STEPS IN THE THOUGHT TEXT
1741
+ ## ALWAYS USE A NOTEBOOK (Always for):
1742
+ - ANY task
1743
+ - Before starting development (plan first!)
1744
+ - Projects with multiple files (organize the structure)
1745
+ - Debugging sessions (monitor discoveries)
1746
+ - Extensive refactoring (map the changes)
1747
+ - Architectural decisions (think through the options)
1748
+
1749
+ ## HOW TO USE A NOTEBOOK:
1750
+ 1. Start with **reasoning_nootebook**
1751
+ 2. Break the task down into logical steps
1752
+ 3. Plan the approach - Which files? What changes? What order?
1753
+ 4. Track progress - Check off completed steps
1754
+ 5. Write down decisions - Why did you choose this approach?
1755
+ 6. Update continuously - Keep the notebook up to date
1756
+
1757
+ ## THE NOTEBOOK PREVENTS:
1758
+ - Acting "outside the box"
1759
+ - Forgetting task requirements
1760
+ - Losing control of complex workflows
1761
+ - Making unplanned changes
1762
+ - Ineffective approaches
1763
+ - Working without a clear roadmap
1764
+ - Jumping between unrelated subtasks
1765
+ </reasoning_rules>
1766
+
1767
+ ---
1768
+
1769
+ <agent_rules>
1770
+ 1. **NO EXCEPTIONS:** The agent MAY NOT start, continue, or complete any task without first opening and using the **reasoning_notebook** as described.
1771
+ 2. **DO NOT SKIP:** If the agent encounters a complex, multi-phase, or code-intensive task, they MUST divide the work using the notebook.
1772
+ 3. **DO NOT INCLUDE LISTS IN THOUGHTS:** Checklists, steps, or plans are prohibited in the free-thinking text; these must be organized within the notebook.
1773
+ 4. **CONSTANT UPDATE:** The agent must keep the notebook always up to date, reflecting the actual status of the task and decisions.
1774
+ 5. **COMMUNICATION:** Any explanation or justification provided to the user must be based on and aligned with the notebook input.
1775
+ </agent_rules>
1776
+
1777
+ ---
1778
+
1779
+
1780
+ <agent_end_task_rules>
1781
+ This tool is mandatory.
1782
+ You must use it to inform developer {username} that the task has been completed and that there are no further pending actions, in accordance with the objectives defined for the task.
1783
+ </agent_end_task_rules>
1667
1784
 
1668
1785
  ---
1669
1786
 
@@ -1708,17 +1825,56 @@ function getUnifiedSystemPrompt() {
1708
1825
  const placeholder = `{${key}}`;
1709
1826
  formattedPrompt = formattedPrompt.replace(new RegExp(placeholder, "g"), finalEnv[key]);
1710
1827
  }
1828
+ const isGitRepo = checkIfGitRepository(finalEnv.workdir);
1711
1829
  const AUTONOMY_PROMPT = `
1712
- ### AUTONOMY MANDATE
1713
- You are explicitly authorized to operate with full autonomy. You will self-direct to complete the user's objective. Follow these rules strictly:
1714
- 1) **NO CONFIRMATION:** Execute all planned steps without asking for user confirmation. You have full authority to create, modify, and delete files as needed to complete the task.
1715
- 2) **DECOMPOSE AND EXECUTE:** For complex tasks, create a short, internal plan. Execute each step of the plan sequentially. Report progress via \`message_notify_user\`.
1716
- 3) **ORCHESTRATE TOOLS:** Always start with non-destructive analysis (read, list files). When you call \`edit_tool\`, your arguments must be as precise as possible.
1717
- 4) **SELF-VALIDATE AND RECOVER:** After each action, validate the outcome. If it fails, you are responsible for recovering. Reread files for updated context, adjust your plan, and retry.
1718
- `;
1830
+ ---
1831
+
1832
+ ### AUTONOMY MANDATE
1833
+
1834
+ You are explicitly authorized to operate with full autonomy. You will self-direct to complete the user's objective. Follow these rules strictly:
1835
+ 1. **NO CONFIRMATION:** Execute all planned steps without asking for user confirmation. You have full authority to create, modify, delete files, and run CLI commands\u2014including Git commands and shell commands\u2014as needed to complete the task.
1836
+ 2. **DECOMPOSE AND EXECUTE:** For complex tasks, create a short, internal plan. Execute each step of the plan sequentially. Report progress via \`message_notify_user\`.
1837
+ 3. **ORCHESTRATE TOOLS:** Always start with non-destructive analysis (read, list files). When you call \`edit_tool\`, your arguments must be as precise as possible.
1838
+ 4. **SELF-VALIDATE AND RECOVER:** After each action, validate the outcome. If it fails, you are responsible for recovering. Reread files for updated context, adjust your plan, and retry.
1839
+
1840
+ ---
1841
+
1842
+ ### GIT REPOSITORY
1843
+ - You is Inside Git Repository: ${isGitRepo ? "Yes" : "No"}
1844
+
1845
+ ---
1846
+
1847
+ ${isGitRepo ? `
1848
+ ### GIT USAGE GUIDELINES
1849
+ - The current working (project) directory is being managed by a git repository.
1850
+ - When asked to commit changes or prepare a commit, always start by gathering information using shell commands:
1851
+ - \`git status\` to ensure that all relevant files are tracked and staged, using \`git add ...\` as needed.
1852
+ - \`git diff HEAD\` to review all changes (including unstaged changes) to tracked files in work tree since last commit.
1853
+ - \`git diff --staged\` to review only staged changes when a partial commit makes sense or was requested by the user.
1854
+ - \`git log -n 3\` to review recent commit messages and match their style (verbosity, formatting, signature line, etc.)
1855
+ - Combine shell commands whenever possible to save time/steps, e.g. \`git status && git diff HEAD && git log -n 3\`.
1856
+ - Always propose a draft commit message. Never just ask the user to give you the full commit message.
1857
+ - Prefer commit messages that are clear, concise, and focused more on "why" and less on "what".
1858
+ - Keep the user informed and ask for clarification or confirmation where needed.
1859
+ - After each commit, confirm that it was successful by running \`git status\`.
1860
+ - If a commit fails, never attempt to work around the issues without being asked to do so.
1861
+ - Never push changes to a remote repository without being asked explicitly by the user.
1862
+ ` : ""}
1863
+
1864
+ ---
1865
+
1866
+ `;
1719
1867
  return `${formattedPrompt}
1720
1868
  ${AUTONOMY_PROMPT}`;
1721
1869
  }
1870
+ function checkIfGitRepository(dirPath) {
1871
+ const gitPath = path8.join(dirPath, ".git");
1872
+ try {
1873
+ return fs9.existsSync(gitPath) && fs9.lstatSync(gitPath).isDirectory();
1874
+ } catch {
1875
+ return false;
1876
+ }
1877
+ }
1722
1878
 
1723
1879
  // src/app/agent/core/context-api/context_manager.ts
1724
1880
  function createApiContextWindow(fullHistory, maxTurns) {
@@ -1893,7 +2049,7 @@ var BluMaAgent = class {
1893
2049
 
1894
2050
  ${editData.error.display}`;
1895
2051
  }
1896
- const filename = path8.basename(toolArgs.file_path);
2052
+ const filename = path9.basename(toolArgs.file_path);
1897
2053
  return createDiff(filename, editData.currentContent || "", editData.newContent);
1898
2054
  } catch (e) {
1899
2055
  return `An unexpected error occurred while generating the edit preview: ${e.message}`;
@@ -2412,7 +2568,7 @@ var SubAgentsBluMa = class {
2412
2568
  };
2413
2569
 
2414
2570
  // src/app/agent/agent.ts
2415
- var globalEnvPath = path9.join(os7.homedir(), ".bluma-cli", ".env");
2571
+ var globalEnvPath = path10.join(os7.homedir(), ".bluma-cli", ".env");
2416
2572
  dotenv.config({ path: globalEnvPath });
2417
2573
  var Agent = class {
2418
2574
  sessionId;
@@ -3018,21 +3174,21 @@ var SlashCommands_default = SlashCommands;
3018
3174
  import updateNotifier from "update-notifier";
3019
3175
  import { readPackageUp } from "read-package-up";
3020
3176
  import { fileURLToPath as fileURLToPath3 } from "url";
3021
- import path10 from "path";
3022
- import fs9 from "fs";
3177
+ import path11 from "path";
3178
+ import fs10 from "fs";
3023
3179
  function findPackageJsonNearest(startDir) {
3024
3180
  let dir = startDir;
3025
3181
  for (let i = 0; i < 6; i++) {
3026
- const candidate = path10.join(dir, "package.json");
3027
- if (fs9.existsSync(candidate)) {
3182
+ const candidate = path11.join(dir, "package.json");
3183
+ if (fs10.existsSync(candidate)) {
3028
3184
  try {
3029
- const raw = fs9.readFileSync(candidate, "utf8");
3185
+ const raw = fs10.readFileSync(candidate, "utf8");
3030
3186
  const parsed = JSON.parse(raw);
3031
3187
  if (parsed?.name && parsed?.version) return parsed;
3032
3188
  } catch {
3033
3189
  }
3034
3190
  }
3035
- const parent = path10.dirname(dir);
3191
+ const parent = path11.dirname(dir);
3036
3192
  if (parent === dir) break;
3037
3193
  dir = parent;
3038
3194
  }
@@ -3045,15 +3201,15 @@ async function checkForUpdates() {
3045
3201
  }
3046
3202
  const binPath = process.argv?.[1];
3047
3203
  let pkg;
3048
- if (binPath && fs9.existsSync(binPath)) {
3049
- const candidatePkg = findPackageJsonNearest(path10.dirname(binPath));
3204
+ if (binPath && fs10.existsSync(binPath)) {
3205
+ const candidatePkg = findPackageJsonNearest(path11.dirname(binPath));
3050
3206
  if (candidatePkg?.name && candidatePkg?.version) {
3051
3207
  pkg = candidatePkg;
3052
3208
  }
3053
3209
  }
3054
3210
  if (!pkg) {
3055
3211
  const __filename = fileURLToPath3(import.meta.url);
3056
- const __dirname = path10.dirname(__filename);
3212
+ const __dirname = path11.dirname(__filename);
3057
3213
  const result = await readPackageUp({ cwd: __dirname });
3058
3214
  pkg = result?.packageJson;
3059
3215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomad-e/bluma-cli",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "BluMa independent agent for automation and advanced software engineering.",
5
5
  "author": "Alex Fonseca",
6
6
  "license": "Apache-2.0",