bugzero 0.0.3 → 0.0.4

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > bugzero@0.0.1 build D:\WD projects\OpsPilot\packages\cli
2
+ > bugzero@0.0.4 build D:\WD projects\OpsPilot\packages\cli
3
3
  > tsup src/index.ts --format esm --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -7,8 +7,10 @@
7
7
  CLI tsup v8.5.1
8
8
  CLI Target: es2022
9
9
  ESM Build start
10
- ESM dist\index.js 41.55 KB
11
- ESM ⚡️ Build success in 165ms
10
+ ESM dist\index.js 31.38 KB
11
+ ESM dist\chunk-4ANZDGVD.js 16.11 KB
12
+ ESM dist\dist-FQYNA36C.js 85.00 B
13
+ ESM ⚡️ Build success in 133ms
12
14
  DTS Build start
13
- DTS ⚡️ Build success in 1740ms
15
+ DTS ⚡️ Build success in 1828ms
14
16
  DTS dist\index.d.ts 20.00 B
package/README.md CHANGED
@@ -13,21 +13,43 @@ Designed for modern developer loops, CI/CD pipelines, and automated hotfixes.
13
13
 
14
14
  ## 🛠️ How it Works
15
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
16
+ ```
17
+ bugzero rescue
18
+ │
19
+ ▼
20
+ Run Build + Lint + Tests
21
+ │
22
+ ▼
23
+ Any failures? ──── No ──▶ ✅ Exit cleanly
24
+ │
25
+ Yes
26
+ │
27
+ ▼
28
+ Capture error logs
29
+ │
30
+ ▼
31
+ Prompt LLM via LangGraph
32
+ │
33
+ ▼
34
+ Parse fix suggestion (JSON)
35
+ │
36
+ ▼
37
+ Apply search-and-replace patch
38
+ │
39
+ ▼
40
+ Re-run build to verify
41
+ │
42
+ ▼
43
+ Build fixed? ─── Yes ──▶ ✅ Print fix details & Exit
44
+ │
45
+ No
46
+ │
47
+ ▼
48
+ Max attempts reached? ── Yes ──▶ ❌ Exit with logs
49
+ │
50
+ No
51
+ │
52
+ └──────────────────▶ Prompt LLM again (loop)
31
53
  ```
32
54
 
33
55
  ---
@@ -51,7 +73,7 @@ npm install -g bugzero
51
73
  ```
52
74
 
53
75
  ### 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:
76
+ BugZero relies on OpenRouter to access AI models (such as DeepSeek, Claude, Gemini, or GPT-4o). 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
77
 
56
78
  **On macOS/Linux:**
57
79
  ```bash
@@ -0,0 +1,426 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // ../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js
34
+ var require_main = __commonJS({
35
+ "../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js"(exports, module) {
36
+ "use strict";
37
+ var fs = __require("fs");
38
+ var path = __require("path");
39
+ var os = __require("os");
40
+ var crypto = __require("crypto");
41
+ var TIPS = [
42
+ "\u25C8 encrypted .env [www.dotenvx.com]",
43
+ "\u25C8 secrets for agents [www.dotenvx.com]",
44
+ "\u2301 auth for agents [www.vestauth.com]",
45
+ "\u2318 custom filepath { path: '/custom/path/.env' }",
46
+ "\u2318 enable debugging { debug: true }",
47
+ "\u2318 override existing { override: true }",
48
+ "\u2318 suppress logs { quiet: true }",
49
+ "\u2318 multiple files { path: ['.env.local', '.env'] }"
50
+ ];
51
+ function _getRandomTip() {
52
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
53
+ }
54
+ function parseBoolean(value) {
55
+ if (typeof value === "string") {
56
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
57
+ }
58
+ return Boolean(value);
59
+ }
60
+ function supportsAnsi() {
61
+ return process.stdout.isTTY;
62
+ }
63
+ function dim(text) {
64
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
65
+ }
66
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
67
+ function parse(src) {
68
+ const obj = {};
69
+ let lines = src.toString();
70
+ lines = lines.replace(/\r\n?/mg, "\n");
71
+ let match;
72
+ while ((match = LINE.exec(lines)) != null) {
73
+ const key = match[1];
74
+ let value = match[2] || "";
75
+ value = value.trim();
76
+ const maybeQuote = value[0];
77
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
78
+ if (maybeQuote === '"') {
79
+ value = value.replace(/\\n/g, "\n");
80
+ value = value.replace(/\\r/g, "\r");
81
+ }
82
+ obj[key] = value;
83
+ }
84
+ return obj;
85
+ }
86
+ function _parseVault(options) {
87
+ options = options || {};
88
+ const vaultPath = _vaultPath(options);
89
+ options.path = vaultPath;
90
+ const result = DotenvModule.configDotenv(options);
91
+ if (!result.parsed) {
92
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
93
+ err.code = "MISSING_DATA";
94
+ throw err;
95
+ }
96
+ const keys = _dotenvKey(options).split(",");
97
+ const length = keys.length;
98
+ let decrypted;
99
+ for (let i = 0; i < length; i++) {
100
+ try {
101
+ const key = keys[i].trim();
102
+ const attrs = _instructions(result, key);
103
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
104
+ break;
105
+ } catch (error) {
106
+ if (i + 1 >= length) {
107
+ throw error;
108
+ }
109
+ }
110
+ }
111
+ return DotenvModule.parse(decrypted);
112
+ }
113
+ function _warn(message) {
114
+ console.error(`\u26A0 ${message}`);
115
+ }
116
+ function _debug(message) {
117
+ console.log(`\u2506 ${message}`);
118
+ }
119
+ function _log(message) {
120
+ console.log(`\u25C7 ${message}`);
121
+ }
122
+ function _dotenvKey(options) {
123
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
124
+ return options.DOTENV_KEY;
125
+ }
126
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
127
+ return process.env.DOTENV_KEY;
128
+ }
129
+ return "";
130
+ }
131
+ function _instructions(result, dotenvKey) {
132
+ let uri;
133
+ try {
134
+ uri = new URL(dotenvKey);
135
+ } catch (error) {
136
+ if (error.code === "ERR_INVALID_URL") {
137
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
138
+ err.code = "INVALID_DOTENV_KEY";
139
+ throw err;
140
+ }
141
+ throw error;
142
+ }
143
+ const key = uri.password;
144
+ if (!key) {
145
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
146
+ err.code = "INVALID_DOTENV_KEY";
147
+ throw err;
148
+ }
149
+ const environment = uri.searchParams.get("environment");
150
+ if (!environment) {
151
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
152
+ err.code = "INVALID_DOTENV_KEY";
153
+ throw err;
154
+ }
155
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
156
+ const ciphertext = result.parsed[environmentKey];
157
+ if (!ciphertext) {
158
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
159
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
160
+ throw err;
161
+ }
162
+ return { ciphertext, key };
163
+ }
164
+ function _vaultPath(options) {
165
+ let possibleVaultPath = null;
166
+ if (options && options.path && options.path.length > 0) {
167
+ if (Array.isArray(options.path)) {
168
+ for (const filepath of options.path) {
169
+ if (fs.existsSync(filepath)) {
170
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
171
+ }
172
+ }
173
+ } else {
174
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
175
+ }
176
+ } else {
177
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
178
+ }
179
+ if (fs.existsSync(possibleVaultPath)) {
180
+ return possibleVaultPath;
181
+ }
182
+ return null;
183
+ }
184
+ function _resolveHome(envPath) {
185
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
186
+ }
187
+ function _configVault(options) {
188
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
189
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
190
+ if (debug || !quiet) {
191
+ _log("loading env from encrypted .env.vault");
192
+ }
193
+ const parsed = DotenvModule._parseVault(options);
194
+ let processEnv = process.env;
195
+ if (options && options.processEnv != null) {
196
+ processEnv = options.processEnv;
197
+ }
198
+ DotenvModule.populate(processEnv, parsed, options);
199
+ return { parsed };
200
+ }
201
+ function configDotenv(options) {
202
+ const dotenvPath = path.resolve(process.cwd(), ".env");
203
+ let encoding = "utf8";
204
+ let processEnv = process.env;
205
+ if (options && options.processEnv != null) {
206
+ processEnv = options.processEnv;
207
+ }
208
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
209
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
210
+ if (options && options.encoding) {
211
+ encoding = options.encoding;
212
+ } else {
213
+ if (debug) {
214
+ _debug("no encoding is specified (UTF-8 is used by default)");
215
+ }
216
+ }
217
+ let optionPaths = [dotenvPath];
218
+ if (options && options.path) {
219
+ if (!Array.isArray(options.path)) {
220
+ optionPaths = [_resolveHome(options.path)];
221
+ } else {
222
+ optionPaths = [];
223
+ for (const filepath of options.path) {
224
+ optionPaths.push(_resolveHome(filepath));
225
+ }
226
+ }
227
+ }
228
+ let lastError;
229
+ const parsedAll = {};
230
+ for (const path2 of optionPaths) {
231
+ try {
232
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
233
+ DotenvModule.populate(parsedAll, parsed, options);
234
+ } catch (e) {
235
+ if (debug) {
236
+ _debug(`failed to load ${path2} ${e.message}`);
237
+ }
238
+ lastError = e;
239
+ }
240
+ }
241
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
242
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
243
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
244
+ if (debug || !quiet) {
245
+ const keysCount = Object.keys(populated).length;
246
+ const shortPaths = [];
247
+ for (const filePath of optionPaths) {
248
+ try {
249
+ const relative = path.relative(process.cwd(), filePath);
250
+ shortPaths.push(relative);
251
+ } catch (e) {
252
+ if (debug) {
253
+ _debug(`failed to load ${filePath} ${e.message}`);
254
+ }
255
+ lastError = e;
256
+ }
257
+ }
258
+ _log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
259
+ }
260
+ if (lastError) {
261
+ return { parsed: parsedAll, error: lastError };
262
+ } else {
263
+ return { parsed: parsedAll };
264
+ }
265
+ }
266
+ function config(options) {
267
+ if (_dotenvKey(options).length === 0) {
268
+ return DotenvModule.configDotenv(options);
269
+ }
270
+ const vaultPath = _vaultPath(options);
271
+ if (!vaultPath) {
272
+ _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
273
+ return DotenvModule.configDotenv(options);
274
+ }
275
+ return DotenvModule._configVault(options);
276
+ }
277
+ function decrypt(encrypted, keyStr) {
278
+ const key = Buffer.from(keyStr.slice(-64), "hex");
279
+ let ciphertext = Buffer.from(encrypted, "base64");
280
+ const nonce = ciphertext.subarray(0, 12);
281
+ const authTag = ciphertext.subarray(-16);
282
+ ciphertext = ciphertext.subarray(12, -16);
283
+ try {
284
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
285
+ aesgcm.setAuthTag(authTag);
286
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
287
+ } catch (error) {
288
+ const isRange = error instanceof RangeError;
289
+ const invalidKeyLength = error.message === "Invalid key length";
290
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
291
+ if (isRange || invalidKeyLength) {
292
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
293
+ err.code = "INVALID_DOTENV_KEY";
294
+ throw err;
295
+ } else if (decryptionFailed) {
296
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
297
+ err.code = "DECRYPTION_FAILED";
298
+ throw err;
299
+ } else {
300
+ throw error;
301
+ }
302
+ }
303
+ }
304
+ function populate(processEnv, parsed, options = {}) {
305
+ const debug = Boolean(options && options.debug);
306
+ const override = Boolean(options && options.override);
307
+ const populated = {};
308
+ if (typeof parsed !== "object") {
309
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
310
+ err.code = "OBJECT_REQUIRED";
311
+ throw err;
312
+ }
313
+ for (const key of Object.keys(parsed)) {
314
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
315
+ if (override === true) {
316
+ processEnv[key] = parsed[key];
317
+ populated[key] = parsed[key];
318
+ }
319
+ if (debug) {
320
+ if (override === true) {
321
+ _debug(`"${key}" is already defined and WAS overwritten`);
322
+ } else {
323
+ _debug(`"${key}" is already defined and was NOT overwritten`);
324
+ }
325
+ }
326
+ } else {
327
+ processEnv[key] = parsed[key];
328
+ populated[key] = parsed[key];
329
+ }
330
+ }
331
+ return populated;
332
+ }
333
+ var DotenvModule = {
334
+ configDotenv,
335
+ _configVault,
336
+ _parseVault,
337
+ config,
338
+ decrypt,
339
+ parse,
340
+ populate
341
+ };
342
+ module.exports.configDotenv = DotenvModule.configDotenv;
343
+ module.exports._configVault = DotenvModule._configVault;
344
+ module.exports._parseVault = DotenvModule._parseVault;
345
+ module.exports.config = DotenvModule.config;
346
+ module.exports.decrypt = DotenvModule.decrypt;
347
+ module.exports.parse = DotenvModule.parse;
348
+ module.exports.populate = DotenvModule.populate;
349
+ module.exports = DotenvModule;
350
+ }
351
+ });
352
+
353
+ // ../config/dist/index.js
354
+ var require_dist = __commonJS({
355
+ "../config/dist/index.js"(exports, module) {
356
+ var __create2 = Object.create;
357
+ var __defProp2 = Object.defineProperty;
358
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
359
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
360
+ var __getProtoOf2 = Object.getPrototypeOf;
361
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
362
+ var __export = (target, all) => {
363
+ for (var name in all)
364
+ __defProp2(target, name, { get: all[name], enumerable: true });
365
+ };
366
+ var __copyProps2 = (to, from, except, desc) => {
367
+ if (from && typeof from === "object" || typeof from === "function") {
368
+ for (let key of __getOwnPropNames2(from))
369
+ if (!__hasOwnProp2.call(to, key) && key !== except)
370
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
371
+ }
372
+ return to;
373
+ };
374
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
375
+ // If the importer is in node compatibility mode or this is not an ESM
376
+ // file that has been converted to a CommonJS file using a Babel-
377
+ // compatible transform (i.e. "__esModule" has not been set), then set
378
+ // "default" to the CommonJS "module.exports" for node compatibility.
379
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
380
+ mod
381
+ ));
382
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
383
+ var index_exports = {};
384
+ __export(index_exports, {
385
+ env: () => env,
386
+ getLocalConfig: () => getLocalConfig,
387
+ getSelectedModel: () => getSelectedModel,
388
+ saveLocalConfig: () => saveLocalConfig
389
+ });
390
+ module.exports = __toCommonJS(index_exports);
391
+ var import_dotenv = __toESM2(require_main());
392
+ import_dotenv.default.config();
393
+ var env = {
394
+ openRouterKey: process.env.OPENROUTER_API_KEY
395
+ };
396
+ var import_fs = __toESM2(__require("fs"));
397
+ var import_path = __toESM2(__require("path"));
398
+ var CONFIG_FILENAME = ".bugzerorc";
399
+ function getLocalConfig(cwd = process.cwd()) {
400
+ try {
401
+ const configPath = import_path.default.resolve(cwd, CONFIG_FILENAME);
402
+ if (import_fs.default.existsSync(configPath)) {
403
+ const content = import_fs.default.readFileSync(configPath, "utf-8");
404
+ return JSON.parse(content);
405
+ }
406
+ } catch (e) {
407
+ }
408
+ return {};
409
+ }
410
+ function saveLocalConfig(config, cwd = process.cwd()) {
411
+ const configPath = import_path.default.resolve(cwd, CONFIG_FILENAME);
412
+ import_fs.default.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
413
+ }
414
+ function getSelectedModel(cwd = process.cwd()) {
415
+ const config = getLocalConfig(cwd);
416
+ return config.model || "deepseek/deepseek-chat";
417
+ }
418
+ }
419
+ });
420
+
421
+ export {
422
+ __require,
423
+ __commonJS,
424
+ __toESM,
425
+ require_dist
426
+ };
@@ -0,0 +1,4 @@
1
+ import {
2
+ require_dist
3
+ } from "./chunk-4ANZDGVD.js";
4
+ export default require_dist();