bugzero 0.0.49 → 0.0.51
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 +57 -12
- 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"));
|
|
@@ -1291,6 +1313,26 @@ var require_dist6 = __commonJS({
|
|
|
1291
1313
|
}
|
|
1292
1314
|
return findWhitespaceNormalizedMatch(content, search) ?? findSimilarityMatch(content, search);
|
|
1293
1315
|
}
|
|
1316
|
+
var CRLF = "\r\n";
|
|
1317
|
+
var LF = "\n";
|
|
1318
|
+
function countEndings(text) {
|
|
1319
|
+
const crlf = text.split(CRLF).length - 1;
|
|
1320
|
+
const lf = text.split(LF).length - 1 - crlf;
|
|
1321
|
+
return { crlf, lf };
|
|
1322
|
+
}
|
|
1323
|
+
function detectLineEnding(text, start, end) {
|
|
1324
|
+
const inside = countEndings(text.slice(start, end));
|
|
1325
|
+
if (inside.crlf !== inside.lf) return inside.crlf > inside.lf ? CRLF : LF;
|
|
1326
|
+
const nextBreak = text.indexOf(LF, end);
|
|
1327
|
+
if (nextBreak !== -1) return text[nextBreak - 1] === "\r" ? CRLF : LF;
|
|
1328
|
+
const previousBreak = start > 0 ? text.lastIndexOf(LF, start - 1) : -1;
|
|
1329
|
+
if (previousBreak !== -1) return text[previousBreak - 1] === "\r" ? CRLF : LF;
|
|
1330
|
+
const whole = countEndings(text);
|
|
1331
|
+
return whole.crlf > whole.lf ? CRLF : LF;
|
|
1332
|
+
}
|
|
1333
|
+
function withLineEnding(text, ending) {
|
|
1334
|
+
return text.replace(/\r\n|\n/g, ending);
|
|
1335
|
+
}
|
|
1294
1336
|
function applyPatch(absoluteFilePath, search, replace, options = {}) {
|
|
1295
1337
|
try {
|
|
1296
1338
|
if (!import_fs2.default.existsSync(absoluteFilePath)) {
|
|
@@ -1311,7 +1353,8 @@ var require_dist6 = __commonJS({
|
|
|
1311
1353
|
if (options.backup !== false) {
|
|
1312
1354
|
import_fs2.default.writeFileSync(backupPath, original, "utf-8");
|
|
1313
1355
|
}
|
|
1314
|
-
const
|
|
1356
|
+
const replacement = withLineEnding(replace, detectLineEnding(original, match.start, match.end));
|
|
1357
|
+
const fixed = original.slice(0, match.start) + replacement + original.slice(match.end);
|
|
1315
1358
|
import_fs2.default.writeFileSync(absoluteFilePath, fixed, "utf-8");
|
|
1316
1359
|
return { success: true, backupPath, matchStrategy: match.strategy };
|
|
1317
1360
|
} catch (err) {
|
|
@@ -2248,6 +2291,7 @@ program.command("hunt").description("Run build, lint, and tests \u2014 report is
|
|
|
2248
2291
|
if (json) routeLogsToStderr();
|
|
2249
2292
|
try {
|
|
2250
2293
|
const cwd = import_path.default.resolve(opts.path);
|
|
2294
|
+
(0, import_config.loadProjectEnv)(cwd);
|
|
2251
2295
|
const timeoutSeconds = parseTimeout(opts.timeout);
|
|
2252
2296
|
const framework = (0, import_core.detectFramework)(cwd);
|
|
2253
2297
|
const packageManager = (0, import_core.detectPackageManager)(cwd);
|
|
@@ -2287,6 +2331,7 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
2287
2331
|
if (json) routeLogsToStderr();
|
|
2288
2332
|
try {
|
|
2289
2333
|
const cwd = import_path.default.resolve(opts.path);
|
|
2334
|
+
(0, import_config.loadProjectEnv)(cwd);
|
|
2290
2335
|
const maxAttempts = (0, import_core.resolveMaxAttempts)(Number(opts.maxAttempts));
|
|
2291
2336
|
const timeoutSeconds = parseTimeout(opts.timeout);
|
|
2292
2337
|
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.51",
|
|
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)",
|