bugzero 0.0.1 ā 0.0.3
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 +143 -0
- package/package.json +3 -3
- package/src/index.ts +94 -7
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# š BugZero
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/bugzero)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://pnpm.io/)
|
|
6
|
+
[](https://github.com/Saksham1800t)
|
|
7
|
+
|
|
8
|
+
**BugZero** is an autonomous, AI-powered self-healing command-line tool. It monitors build, lint, and test errors in your project, analyzes them using an LLM, generates precise surgical code patches, applies them safely, and runs validation loops recursively until your build is completely green.
|
|
9
|
+
|
|
10
|
+
Designed for modern developer loops, CI/CD pipelines, and automated hotfixes.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## š ļø How it Works
|
|
15
|
+
|
|
16
|
+
```mermaid
|
|
17
|
+
graph TD
|
|
18
|
+
A[Start: bugzero rescue] --> B[Run build, lint, and test scripts]
|
|
19
|
+
B --> C{Any Failures?}
|
|
20
|
+
C -- No --> D[Success: Exits cleanly]
|
|
21
|
+
C -- Yes --> E[Capture error outputs and logs]
|
|
22
|
+
E --> F[Prompt LLM via LangGraph Agent]
|
|
23
|
+
F --> G[Parse Structured Fix Suggestion]
|
|
24
|
+
G --> H[Apply Precise Search & Replace Patch]
|
|
25
|
+
H --> I[Verify build and validation tests]
|
|
26
|
+
I --> J{Build Fixed?}
|
|
27
|
+
J -- Yes --> K[ā
Output Fix Details & Exit]
|
|
28
|
+
J -- No --> L{Max attempts reached?}
|
|
29
|
+
L -- Yes --> M[ā Exit failure with logs]
|
|
30
|
+
L -- No --> F
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## š Key Features
|
|
36
|
+
|
|
37
|
+
* **š Automatic Framework Detection**: Detects common web frameworks and tooling setups inside your target directories.
|
|
38
|
+
* **š¤ LangGraph-Based Feedback Loop**: Employs stateful graphs to analyze compiler/test outputs, write minimal patches, and re-run compilation checks recursively.
|
|
39
|
+
* **ā” Surgical Search-and-Replace**: Avoids corrupting files by using highly specific search-and-replace strings generated directly from the abstract syntax context.
|
|
40
|
+
* **š¦ Safe Backups**: Creates a backup `.bugzero.bak` for every modified file so you can revert modifications easily.
|
|
41
|
+
* **š Multiple Checkups**: Validates builds, style guidelines (ESLint), and testing frameworks (Jest) automatically.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## š Getting Started
|
|
46
|
+
|
|
47
|
+
### 1. Global Installation
|
|
48
|
+
Install `bugzero` globally from NPM:
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g bugzero
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Configure Environment Variables
|
|
54
|
+
BugZero relies on OpenRouter to access Claude. Configure your environment variable in your terminal session or add it to a `.env` file at the root of the project you are fixing:
|
|
55
|
+
|
|
56
|
+
**On macOS/Linux:**
|
|
57
|
+
```bash
|
|
58
|
+
export OPENROUTER_API_KEY="your_openrouter_api_key_here"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**On Windows (PowerShell):**
|
|
62
|
+
```powershell
|
|
63
|
+
$env:OPENROUTER_API_KEY="your_openrouter_api_key_here"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## š» Usage & Commands
|
|
69
|
+
|
|
70
|
+
Run `bugzero` from any terminal directory.
|
|
71
|
+
|
|
72
|
+
### 1. Hunt for Bugs (Dry-Run / Safe Check)
|
|
73
|
+
Run build, lint, and test checks to report error diagnostics without modifying any files.
|
|
74
|
+
```bash
|
|
75
|
+
bugzero hunt --path /path/to/your/project
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. Rescue Your Project (Autonomous Mode)
|
|
79
|
+
Run the AI repair loop to automatically detect compilation errors, generate code patches, apply them, and verify the build.
|
|
80
|
+
```bash
|
|
81
|
+
bugzero rescue --path /path/to/your/project
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. Vibe With a Brain (Change AI Model)
|
|
85
|
+
List and select which LLM model you want to use. This fetches the latest available models from OpenRouter, lets you pick one, and saves it inside `.bugzerorc`.
|
|
86
|
+
```bash
|
|
87
|
+
bugzero vibe
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### CLI Command Options
|
|
91
|
+
|
|
92
|
+
| Option | Shorthand | Description | Default |
|
|
93
|
+
| :--- | :--- | :--- | :--- |
|
|
94
|
+
| `--path <dir>` | `-p <dir>` | The path to the target project you want to check/fix | `.` (Current directory) |
|
|
95
|
+
| `--max-attempts <num>` | `-n <num>` | Maximum AI fix loops/attempts before giving up | `3` |
|
|
96
|
+
| `--dry-run` | | Print the recommended fixes without saving changes to files | `false` |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## š§± Monorepo Development & Local Setup
|
|
101
|
+
|
|
102
|
+
If you want to contribute to the BugZero engine:
|
|
103
|
+
|
|
104
|
+
### Prerequisites
|
|
105
|
+
* Node.js (LTS version recommended)
|
|
106
|
+
* `pnpm` (workspace manager)
|
|
107
|
+
|
|
108
|
+
### Installation
|
|
109
|
+
Clone the repository, go into the workspace root, and run:
|
|
110
|
+
```bash
|
|
111
|
+
pnpm install
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Local Commands
|
|
115
|
+
* **Build all monorepo packages**:
|
|
116
|
+
```bash
|
|
117
|
+
pnpm build
|
|
118
|
+
```
|
|
119
|
+
* **Run CLI locally in development mode (shortcuts)**:
|
|
120
|
+
```bash
|
|
121
|
+
pnpm hunt --path ./demo-project
|
|
122
|
+
pnpm rescue --path ./demo-project
|
|
123
|
+
pnpm vibe
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## š„ Author
|
|
129
|
+
|
|
130
|
+
Made with ā¤ļø and š by:
|
|
131
|
+
|
|
132
|
+
* **Name**: Saksham Agarwal
|
|
133
|
+
* **Email**: [sakshamagarwal0507@gmail.com](mailto:sakshamagarwal0507@gmail.com)
|
|
134
|
+
* **GitHub**: [@Saksham1800t](https://github.com/Saksham1800t)
|
|
135
|
+
* **LinkedIn**: [Saksham Agarwal](https://www.linkedin.com/in/saksham-agarwal-/)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## ā Support My Work
|
|
140
|
+
|
|
141
|
+
If BugZero saved you debugging hours in production or deployment pipelines, support the project!
|
|
142
|
+
|
|
143
|
+
[](https://www.buymeacoffee.com/saksham_)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugzero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"bin": {
|
|
5
5
|
"bugzero": "dist/index.js"
|
|
6
6
|
},
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@opspilot/agents": "0.0.1",
|
|
16
|
-
"@opspilot/
|
|
17
|
-
"@opspilot/
|
|
16
|
+
"@opspilot/core": "0.0.1",
|
|
17
|
+
"@opspilot/config": "0.0.1"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/index.js",
|
|
20
20
|
"types": "./dist/index.d.ts",
|
package/src/index.ts
CHANGED
|
@@ -13,9 +13,9 @@ program
|
|
|
13
13
|
.description("AI-powered build issue fixer ā detects and repairs build errors automatically")
|
|
14
14
|
.version("0.0.1");
|
|
15
15
|
|
|
16
|
-
// āā bugzero
|
|
16
|
+
// āā bugzero hunt āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
17
17
|
program
|
|
18
|
-
.command("
|
|
18
|
+
.command("hunt")
|
|
19
19
|
.description("Run build, lint, and tests ā report issues without modifying files")
|
|
20
20
|
.option("-p, --path <dir>", "Path to the target project", ".")
|
|
21
21
|
.action(async (opts) => {
|
|
@@ -53,13 +53,13 @@ program
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const allPassed = build.success && lint.success && test.success;
|
|
56
|
-
console.log(`\n${allPassed ? "ā
All checks passed" : "ā Issues found ā run 'bugzero
|
|
56
|
+
console.log(`\n${allPassed ? "ā
All checks passed" : "ā Issues found ā run 'bugzero rescue' to repair"}\n`);
|
|
57
57
|
process.exit(allPassed ? 0 : 1);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
// āā bugzero
|
|
60
|
+
// āā bugzero rescue āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
61
61
|
program
|
|
62
|
-
.command("
|
|
62
|
+
.command("rescue")
|
|
63
63
|
.description("Detect build failures and automatically apply AI-generated fixes")
|
|
64
64
|
.option("-p, --path <dir>", "Path to the target project", ".")
|
|
65
65
|
.option("-n, --max-attempts <number>", "Maximum AI fix attempts", "3")
|
|
@@ -99,11 +99,98 @@ program
|
|
|
99
99
|
// āā bugzero protect (legacy) āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
100
100
|
program
|
|
101
101
|
.command("protect")
|
|
102
|
-
.description("[Deprecated] Use '
|
|
102
|
+
.description("[Deprecated] Use 'hunt' instead")
|
|
103
103
|
.action(async () => {
|
|
104
|
-
console.warn("ā ļø 'protect' is deprecated ā use 'bugzero
|
|
104
|
+
console.warn("ā ļø 'protect' is deprecated ā use 'bugzero hunt' instead.\n");
|
|
105
105
|
const result = await orchestrate();
|
|
106
106
|
console.log(result);
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
+
// āā bugzero vibe āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
110
|
+
program
|
|
111
|
+
.command("vibe")
|
|
112
|
+
.description("Select which AI model (brain) to use for resolving bugs")
|
|
113
|
+
.action(async () => {
|
|
114
|
+
const { getLocalConfig, saveLocalConfig } = await import("@opspilot/config");
|
|
115
|
+
const readline = await import("readline");
|
|
116
|
+
const axios = (await import("axios")).default;
|
|
117
|
+
|
|
118
|
+
console.log(`\nš§ BugZero Brain Selector`);
|
|
119
|
+
console.log(`āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā`);
|
|
120
|
+
|
|
121
|
+
let popularModels: any[] = [];
|
|
122
|
+
try {
|
|
123
|
+
console.log("š Fetching active models list from OpenRouter...");
|
|
124
|
+
const response = await axios.get("https://openrouter.ai/api/v1/models", { timeout: 8000 });
|
|
125
|
+
const allModels = response.data?.data || [];
|
|
126
|
+
const popularModelIds = [
|
|
127
|
+
"deepseek/deepseek-chat",
|
|
128
|
+
"deepseek/deepseek-r1",
|
|
129
|
+
"anthropic/claude-3.5-sonnet",
|
|
130
|
+
"google/gemini-2.5-pro",
|
|
131
|
+
"google/gemini-2.5-flash",
|
|
132
|
+
"openai/gpt-4o",
|
|
133
|
+
"meta-llama/llama-3.3-70b-instruct"
|
|
134
|
+
];
|
|
135
|
+
popularModels = allModels.filter((m: any) => popularModelIds.includes(m.id));
|
|
136
|
+
} catch (e: any) {
|
|
137
|
+
console.warn("ā ļø Failed to fetch models list from OpenRouter. Using cached default list.");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (popularModels.length === 0) {
|
|
141
|
+
popularModels = [
|
|
142
|
+
{ id: "deepseek/deepseek-chat", name: "DeepSeek V3 (Chat)" },
|
|
143
|
+
{ id: "deepseek/deepseek-r1", name: "DeepSeek R1" },
|
|
144
|
+
{ id: "anthropic/claude-3.5-sonnet", name: "Claude 3.5 Sonnet" },
|
|
145
|
+
{ id: "google/gemini-2.5-pro", name: "Gemini 2.5 Pro" },
|
|
146
|
+
{ id: "google/gemini-2.5-flash", name: "Gemini 2.5 Flash" },
|
|
147
|
+
{ id: "openai/gpt-4o", name: "GPT-4o" },
|
|
148
|
+
{ id: "meta-llama/llama-3.3-70b-instruct", name: "Llama 3.3 Instruct" }
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const currentModel = getLocalConfig().model || "deepseek/deepseek-chat";
|
|
153
|
+
console.log(`\nCurrent active model: \x1b[36m${currentModel}\x1b[0m\n`);
|
|
154
|
+
|
|
155
|
+
popularModels.forEach((m, idx) => {
|
|
156
|
+
console.log(` [${idx + 1}] ${m.name} (${m.id})`);
|
|
157
|
+
});
|
|
158
|
+
console.log(` [${popularModels.length + 1}] šļø Custom Model (Type manually)`);
|
|
159
|
+
console.log();
|
|
160
|
+
|
|
161
|
+
const rl = readline.createInterface({
|
|
162
|
+
input: process.stdin,
|
|
163
|
+
output: process.stdout,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
rl.question(`Select a number (1-${popularModels.length + 1}): `, (answer) => {
|
|
167
|
+
const choice = parseInt(answer.trim(), 10);
|
|
168
|
+
if (isNaN(choice) || choice < 1 || choice > popularModels.length + 1) {
|
|
169
|
+
console.log("ā Invalid selection. Keeping current model.");
|
|
170
|
+
rl.close();
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (choice === popularModels.length + 1) {
|
|
175
|
+
rl.question("Enter custom OpenRouter Model ID (e.g. microsoft/phi-3-medium-128k-instruct): ", (customModel) => {
|
|
176
|
+
const selected = customModel.trim();
|
|
177
|
+
if (!selected) {
|
|
178
|
+
console.log("ā No model entered. Keeping current model.");
|
|
179
|
+
} else {
|
|
180
|
+
saveLocalConfig({ model: selected });
|
|
181
|
+
console.log(`\nā
Saved! Model set to: \x1b[32m${selected}\x1b[0m`);
|
|
182
|
+
console.log(` Saved config to: .bugzerorc`);
|
|
183
|
+
}
|
|
184
|
+
rl.close();
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
const selected = popularModels[choice - 1].id;
|
|
188
|
+
saveLocalConfig({ model: selected });
|
|
189
|
+
console.log(`\nā
Saved! Model set to: \x1b[32m${selected}\x1b[0m`);
|
|
190
|
+
console.log(` Saved config to: .bugzerorc`);
|
|
191
|
+
rl.close();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
109
196
|
program.parse();
|