bugzero 0.0.48 → 0.0.50
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 +4 -2
- package/dist/index.js +50 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,11 +183,13 @@ export OPENROUTER_API_KEY="your_openrouter_api_key_here"
|
|
|
183
183
|
$env:OPENROUTER_API_KEY="your_openrouter_api_key_here"
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
**Or** create a `.env` file in the project
|
|
186
|
+
**Or** create a `.env` file in the project you are targeting (the folder you pass with `--path`, or the current folder if you don't):
|
|
187
187
|
```env
|
|
188
188
|
OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
BugZero uses the closest `.env` at or above that folder. A variable already set in your shell always wins over the file, and the target project's `.env` wins over one in the folder you ran the command from.
|
|
192
|
+
|
|
191
193
|
---
|
|
192
194
|
|
|
193
195
|
## Commands
|
|
@@ -300,7 +302,7 @@ BugZero provides clear, actionable output for common failure modes:
|
|
|
300
302
|
Clone the repository and install dependencies. This project uses a pnpm monorepo managed by Turborepo, with a Vitest test suite and GitHub Actions CI.
|
|
301
303
|
|
|
302
304
|
### Prerequisites
|
|
303
|
-
- Node.js 22.12 or later
|
|
305
|
+
- Node.js 22.12 or later (CI runs the tests on Linux, Windows and macOS with Node 22.12, 22 and 24)
|
|
304
306
|
- pnpm
|
|
305
307
|
|
|
306
308
|
### Install & build
|
package/dist/index.js
CHANGED
|
@@ -382,31 +382,53 @@ var require_dist = __commonJS({
|
|
|
382
382
|
env: () => env,
|
|
383
383
|
getLocalConfig: () => getLocalConfig,
|
|
384
384
|
getSelectedModel: () => getSelectedModel,
|
|
385
|
+
loadProjectEnv: () => loadProjectEnv2,
|
|
385
386
|
saveLocalConfig: () => saveLocalConfig
|
|
386
387
|
});
|
|
387
388
|
module2.exports = __toCommonJS(index_exports);
|
|
388
389
|
var import_dotenv = __toESM2(require_main());
|
|
389
390
|
var import_fs2 = __toESM2(require("fs"));
|
|
390
391
|
var import_path2 = __toESM2(require("path"));
|
|
391
|
-
|
|
392
|
-
|
|
392
|
+
var loadedFromFiles = /* @__PURE__ */ new Map();
|
|
393
|
+
function findEnvFile(startDir) {
|
|
394
|
+
let dir = import_path2.default.resolve(startDir);
|
|
393
395
|
while (true) {
|
|
394
396
|
const envPath = import_path2.default.join(dir, ".env");
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
397
|
+
try {
|
|
398
|
+
if (import_fs2.default.statSync(envPath).isFile()) return envPath;
|
|
399
|
+
} catch {
|
|
398
400
|
}
|
|
399
401
|
const parent = import_path2.default.dirname(dir);
|
|
400
|
-
if (parent === dir)
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
402
|
+
if (parent === dir) return void 0;
|
|
403
403
|
dir = parent;
|
|
404
404
|
}
|
|
405
|
-
import_dotenv.default.config({ quiet: true });
|
|
406
405
|
}
|
|
407
|
-
|
|
406
|
+
function applyEnvFile(envPath) {
|
|
407
|
+
try {
|
|
408
|
+
const parsed = import_dotenv.default.parse(import_fs2.default.readFileSync(envPath));
|
|
409
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
410
|
+
const current = process.env[key];
|
|
411
|
+
if (current === void 0 || current === loadedFromFiles.get(key)) {
|
|
412
|
+
process.env[key] = value;
|
|
413
|
+
loadedFromFiles.set(key, value);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return true;
|
|
417
|
+
} catch {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function loadProjectEnv2(projectDir) {
|
|
422
|
+
const envPath = findEnvFile(projectDir);
|
|
423
|
+
if (!envPath) return void 0;
|
|
424
|
+
return applyEnvFile(envPath) ? envPath : void 0;
|
|
425
|
+
}
|
|
426
|
+
loadProjectEnv2(process.cwd());
|
|
408
427
|
var env = {
|
|
409
|
-
|
|
428
|
+
// Read on access, so a key loaded later by loadProjectEnv() is seen.
|
|
429
|
+
get openRouterKey() {
|
|
430
|
+
return process.env.OPENROUTER_API_KEY || "";
|
|
431
|
+
}
|
|
410
432
|
};
|
|
411
433
|
var import_fs22 = __toESM2(require("fs"));
|
|
412
434
|
var import_path22 = __toESM2(require("path"));
|
|
@@ -1805,7 +1827,8 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
1805
1827
|
success: true,
|
|
1806
1828
|
attempts: 0,
|
|
1807
1829
|
maxAttempts,
|
|
1808
|
-
rawOutput: ""
|
|
1830
|
+
rawOutput: "",
|
|
1831
|
+
alreadyPassing: true
|
|
1809
1832
|
});
|
|
1810
1833
|
return { success: true, attempts: 0, finalOutput: "" };
|
|
1811
1834
|
}
|
|
@@ -1957,7 +1980,19 @@ ${logs}
|
|
|
1957
1980
|
}
|
|
1958
1981
|
} else {
|
|
1959
1982
|
const { success, attempts, maxAttempts, appliedFix, error, rawOutput, modelUsed, promptTokens, completionTokens } = data;
|
|
1960
|
-
if (data.
|
|
1983
|
+
if (data.alreadyPassing) {
|
|
1984
|
+
content = `# \u{1F916} BugZero Rescue Report
|
|
1985
|
+
|
|
1986
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1987
|
+
**Project Path:** \`${cwd}\`
|
|
1988
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1989
|
+
|
|
1990
|
+
## \u{1F4CA} Repair Summary
|
|
1991
|
+
- **Status:** \u2705 Nothing to fix
|
|
1992
|
+
- **Attempts:** 0 / ${maxAttempts}
|
|
1993
|
+
|
|
1994
|
+
Your project already passes its build, lint, and tests, so BugZero made no changes and did not call an AI model.`;
|
|
1995
|
+
} else if (data.dryRun) {
|
|
1961
1996
|
console.log("[BugZero] Calling AI to diagnose the detected errors and write report...");
|
|
1962
1997
|
try {
|
|
1963
1998
|
const result = await provider.invoke(buildDryRunPrompt(cwd, rawOutput ?? ""), { cwd });
|
|
@@ -2235,6 +2270,7 @@ program.command("hunt").description("Run build, lint, and tests \u2014 report is
|
|
|
2235
2270
|
if (json) routeLogsToStderr();
|
|
2236
2271
|
try {
|
|
2237
2272
|
const cwd = import_path.default.resolve(opts.path);
|
|
2273
|
+
(0, import_config.loadProjectEnv)(cwd);
|
|
2238
2274
|
const timeoutSeconds = parseTimeout(opts.timeout);
|
|
2239
2275
|
const framework = (0, import_core.detectFramework)(cwd);
|
|
2240
2276
|
const packageManager = (0, import_core.detectPackageManager)(cwd);
|
|
@@ -2274,6 +2310,7 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
2274
2310
|
if (json) routeLogsToStderr();
|
|
2275
2311
|
try {
|
|
2276
2312
|
const cwd = import_path.default.resolve(opts.path);
|
|
2313
|
+
(0, import_config.loadProjectEnv)(cwd);
|
|
2277
2314
|
const maxAttempts = (0, import_core.resolveMaxAttempts)(Number(opts.maxAttempts));
|
|
2278
2315
|
const timeoutSeconds = parseTimeout(opts.timeout);
|
|
2279
2316
|
const dryRun = opts.dryRun;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugzero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "Autonomous AI-powered CLI and GitHub Action that detects build, lint, and test failures, generates multi-file patches, applies them atomically with fuzzy matching, and re-verifies until your project is green.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Saksham Agarwal (https://github.com/Saksham1800t)",
|