bugzero 0.0.49 → 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.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/dist/index.js +35 -11
  3. 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 root you are targeting:
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
- function loadEnv() {
392
- let dir = process.cwd();
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
- if (import_fs2.default.existsSync(envPath)) {
396
- import_dotenv.default.config({ path: envPath, quiet: true });
397
- return;
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
- loadEnv();
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
- openRouterKey: process.env.OPENROUTER_API_KEY || ""
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"));
@@ -2248,6 +2270,7 @@ program.command("hunt").description("Run build, lint, and tests \u2014 report is
2248
2270
  if (json) routeLogsToStderr();
2249
2271
  try {
2250
2272
  const cwd = import_path.default.resolve(opts.path);
2273
+ (0, import_config.loadProjectEnv)(cwd);
2251
2274
  const timeoutSeconds = parseTimeout(opts.timeout);
2252
2275
  const framework = (0, import_core.detectFramework)(cwd);
2253
2276
  const packageManager = (0, import_core.detectPackageManager)(cwd);
@@ -2287,6 +2310,7 @@ program.command("rescue").description("Detect build failures and automatically a
2287
2310
  if (json) routeLogsToStderr();
2288
2311
  try {
2289
2312
  const cwd = import_path.default.resolve(opts.path);
2313
+ (0, import_config.loadProjectEnv)(cwd);
2290
2314
  const maxAttempts = (0, import_core.resolveMaxAttempts)(Number(opts.maxAttempts));
2291
2315
  const timeoutSeconds = parseTimeout(opts.timeout);
2292
2316
  const dryRun = opts.dryRun;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bugzero",
3
- "version": "0.0.49",
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)",