bugzero 0.0.3 → 0.0.5
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/.turbo/turbo-build.log +6 -4
- package/README.md +189 -74
- package/dist/chunk-4ANZDGVD.js +426 -0
- package/dist/dist-FQYNA36C.js +4 -0
- package/dist/index.js +234 -510
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,421 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
-
}) : x)(function(x) {
|
|
11
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let key of __getOwnPropNames(from))
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
-
mod
|
|
32
|
-
));
|
|
33
|
-
|
|
34
|
-
// ../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js
|
|
35
|
-
var require_main = __commonJS({
|
|
36
|
-
"../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
37
|
-
"use strict";
|
|
38
|
-
var fs = __require("fs");
|
|
39
|
-
var path2 = __require("path");
|
|
40
|
-
var os = __require("os");
|
|
41
|
-
var crypto = __require("crypto");
|
|
42
|
-
var TIPS = [
|
|
43
|
-
"\u25C8 encrypted .env [www.dotenvx.com]",
|
|
44
|
-
"\u25C8 secrets for agents [www.dotenvx.com]",
|
|
45
|
-
"\u2301 auth for agents [www.vestauth.com]",
|
|
46
|
-
"\u2318 custom filepath { path: '/custom/path/.env' }",
|
|
47
|
-
"\u2318 enable debugging { debug: true }",
|
|
48
|
-
"\u2318 override existing { override: true }",
|
|
49
|
-
"\u2318 suppress logs { quiet: true }",
|
|
50
|
-
"\u2318 multiple files { path: ['.env.local', '.env'] }"
|
|
51
|
-
];
|
|
52
|
-
function _getRandomTip() {
|
|
53
|
-
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
54
|
-
}
|
|
55
|
-
function parseBoolean(value) {
|
|
56
|
-
if (typeof value === "string") {
|
|
57
|
-
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
58
|
-
}
|
|
59
|
-
return Boolean(value);
|
|
60
|
-
}
|
|
61
|
-
function supportsAnsi() {
|
|
62
|
-
return process.stdout.isTTY;
|
|
63
|
-
}
|
|
64
|
-
function dim(text) {
|
|
65
|
-
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
66
|
-
}
|
|
67
|
-
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
68
|
-
function parse(src) {
|
|
69
|
-
const obj = {};
|
|
70
|
-
let lines = src.toString();
|
|
71
|
-
lines = lines.replace(/\r\n?/mg, "\n");
|
|
72
|
-
let match;
|
|
73
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
74
|
-
const key = match[1];
|
|
75
|
-
let value = match[2] || "";
|
|
76
|
-
value = value.trim();
|
|
77
|
-
const maybeQuote = value[0];
|
|
78
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
79
|
-
if (maybeQuote === '"') {
|
|
80
|
-
value = value.replace(/\\n/g, "\n");
|
|
81
|
-
value = value.replace(/\\r/g, "\r");
|
|
82
|
-
}
|
|
83
|
-
obj[key] = value;
|
|
84
|
-
}
|
|
85
|
-
return obj;
|
|
86
|
-
}
|
|
87
|
-
function _parseVault(options) {
|
|
88
|
-
options = options || {};
|
|
89
|
-
const vaultPath = _vaultPath(options);
|
|
90
|
-
options.path = vaultPath;
|
|
91
|
-
const result = DotenvModule.configDotenv(options);
|
|
92
|
-
if (!result.parsed) {
|
|
93
|
-
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
94
|
-
err.code = "MISSING_DATA";
|
|
95
|
-
throw err;
|
|
96
|
-
}
|
|
97
|
-
const keys = _dotenvKey(options).split(",");
|
|
98
|
-
const length = keys.length;
|
|
99
|
-
let decrypted;
|
|
100
|
-
for (let i = 0; i < length; i++) {
|
|
101
|
-
try {
|
|
102
|
-
const key = keys[i].trim();
|
|
103
|
-
const attrs = _instructions(result, key);
|
|
104
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
105
|
-
break;
|
|
106
|
-
} catch (error) {
|
|
107
|
-
if (i + 1 >= length) {
|
|
108
|
-
throw error;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return DotenvModule.parse(decrypted);
|
|
113
|
-
}
|
|
114
|
-
function _warn(message) {
|
|
115
|
-
console.error(`\u26A0 ${message}`);
|
|
116
|
-
}
|
|
117
|
-
function _debug(message) {
|
|
118
|
-
console.log(`\u2506 ${message}`);
|
|
119
|
-
}
|
|
120
|
-
function _log(message) {
|
|
121
|
-
console.log(`\u25C7 ${message}`);
|
|
122
|
-
}
|
|
123
|
-
function _dotenvKey(options) {
|
|
124
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
125
|
-
return options.DOTENV_KEY;
|
|
126
|
-
}
|
|
127
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
128
|
-
return process.env.DOTENV_KEY;
|
|
129
|
-
}
|
|
130
|
-
return "";
|
|
131
|
-
}
|
|
132
|
-
function _instructions(result, dotenvKey) {
|
|
133
|
-
let uri;
|
|
134
|
-
try {
|
|
135
|
-
uri = new URL(dotenvKey);
|
|
136
|
-
} catch (error) {
|
|
137
|
-
if (error.code === "ERR_INVALID_URL") {
|
|
138
|
-
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");
|
|
139
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
140
|
-
throw err;
|
|
141
|
-
}
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
const key = uri.password;
|
|
145
|
-
if (!key) {
|
|
146
|
-
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
147
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
148
|
-
throw err;
|
|
149
|
-
}
|
|
150
|
-
const environment = uri.searchParams.get("environment");
|
|
151
|
-
if (!environment) {
|
|
152
|
-
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
153
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
154
|
-
throw err;
|
|
155
|
-
}
|
|
156
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
157
|
-
const ciphertext = result.parsed[environmentKey];
|
|
158
|
-
if (!ciphertext) {
|
|
159
|
-
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
160
|
-
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
161
|
-
throw err;
|
|
162
|
-
}
|
|
163
|
-
return { ciphertext, key };
|
|
164
|
-
}
|
|
165
|
-
function _vaultPath(options) {
|
|
166
|
-
let possibleVaultPath = null;
|
|
167
|
-
if (options && options.path && options.path.length > 0) {
|
|
168
|
-
if (Array.isArray(options.path)) {
|
|
169
|
-
for (const filepath of options.path) {
|
|
170
|
-
if (fs.existsSync(filepath)) {
|
|
171
|
-
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
|
|
179
|
-
}
|
|
180
|
-
if (fs.existsSync(possibleVaultPath)) {
|
|
181
|
-
return possibleVaultPath;
|
|
182
|
-
}
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
function _resolveHome(envPath) {
|
|
186
|
-
return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
187
|
-
}
|
|
188
|
-
function _configVault(options) {
|
|
189
|
-
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
190
|
-
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
191
|
-
if (debug || !quiet) {
|
|
192
|
-
_log("loading env from encrypted .env.vault");
|
|
193
|
-
}
|
|
194
|
-
const parsed = DotenvModule._parseVault(options);
|
|
195
|
-
let processEnv = process.env;
|
|
196
|
-
if (options && options.processEnv != null) {
|
|
197
|
-
processEnv = options.processEnv;
|
|
198
|
-
}
|
|
199
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
200
|
-
return { parsed };
|
|
201
|
-
}
|
|
202
|
-
function configDotenv(options) {
|
|
203
|
-
const dotenvPath = path2.resolve(process.cwd(), ".env");
|
|
204
|
-
let encoding = "utf8";
|
|
205
|
-
let processEnv = process.env;
|
|
206
|
-
if (options && options.processEnv != null) {
|
|
207
|
-
processEnv = options.processEnv;
|
|
208
|
-
}
|
|
209
|
-
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
210
|
-
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
211
|
-
if (options && options.encoding) {
|
|
212
|
-
encoding = options.encoding;
|
|
213
|
-
} else {
|
|
214
|
-
if (debug) {
|
|
215
|
-
_debug("no encoding is specified (UTF-8 is used by default)");
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
let optionPaths = [dotenvPath];
|
|
219
|
-
if (options && options.path) {
|
|
220
|
-
if (!Array.isArray(options.path)) {
|
|
221
|
-
optionPaths = [_resolveHome(options.path)];
|
|
222
|
-
} else {
|
|
223
|
-
optionPaths = [];
|
|
224
|
-
for (const filepath of options.path) {
|
|
225
|
-
optionPaths.push(_resolveHome(filepath));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
let lastError;
|
|
230
|
-
const parsedAll = {};
|
|
231
|
-
for (const path3 of optionPaths) {
|
|
232
|
-
try {
|
|
233
|
-
const parsed = DotenvModule.parse(fs.readFileSync(path3, { encoding }));
|
|
234
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
235
|
-
} catch (e) {
|
|
236
|
-
if (debug) {
|
|
237
|
-
_debug(`failed to load ${path3} ${e.message}`);
|
|
238
|
-
}
|
|
239
|
-
lastError = e;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
243
|
-
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
244
|
-
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
245
|
-
if (debug || !quiet) {
|
|
246
|
-
const keysCount = Object.keys(populated).length;
|
|
247
|
-
const shortPaths = [];
|
|
248
|
-
for (const filePath of optionPaths) {
|
|
249
|
-
try {
|
|
250
|
-
const relative = path2.relative(process.cwd(), filePath);
|
|
251
|
-
shortPaths.push(relative);
|
|
252
|
-
} catch (e) {
|
|
253
|
-
if (debug) {
|
|
254
|
-
_debug(`failed to load ${filePath} ${e.message}`);
|
|
255
|
-
}
|
|
256
|
-
lastError = e;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
_log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
260
|
-
}
|
|
261
|
-
if (lastError) {
|
|
262
|
-
return { parsed: parsedAll, error: lastError };
|
|
263
|
-
} else {
|
|
264
|
-
return { parsed: parsedAll };
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
function config(options) {
|
|
268
|
-
if (_dotenvKey(options).length === 0) {
|
|
269
|
-
return DotenvModule.configDotenv(options);
|
|
270
|
-
}
|
|
271
|
-
const vaultPath = _vaultPath(options);
|
|
272
|
-
if (!vaultPath) {
|
|
273
|
-
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
274
|
-
return DotenvModule.configDotenv(options);
|
|
275
|
-
}
|
|
276
|
-
return DotenvModule._configVault(options);
|
|
277
|
-
}
|
|
278
|
-
function decrypt(encrypted, keyStr) {
|
|
279
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
280
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
|
281
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
282
|
-
const authTag = ciphertext.subarray(-16);
|
|
283
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
284
|
-
try {
|
|
285
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
286
|
-
aesgcm.setAuthTag(authTag);
|
|
287
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
288
|
-
} catch (error) {
|
|
289
|
-
const isRange = error instanceof RangeError;
|
|
290
|
-
const invalidKeyLength = error.message === "Invalid key length";
|
|
291
|
-
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
292
|
-
if (isRange || invalidKeyLength) {
|
|
293
|
-
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
294
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
295
|
-
throw err;
|
|
296
|
-
} else if (decryptionFailed) {
|
|
297
|
-
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
298
|
-
err.code = "DECRYPTION_FAILED";
|
|
299
|
-
throw err;
|
|
300
|
-
} else {
|
|
301
|
-
throw error;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function populate(processEnv, parsed, options = {}) {
|
|
306
|
-
const debug = Boolean(options && options.debug);
|
|
307
|
-
const override = Boolean(options && options.override);
|
|
308
|
-
const populated = {};
|
|
309
|
-
if (typeof parsed !== "object") {
|
|
310
|
-
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
311
|
-
err.code = "OBJECT_REQUIRED";
|
|
312
|
-
throw err;
|
|
313
|
-
}
|
|
314
|
-
for (const key of Object.keys(parsed)) {
|
|
315
|
-
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
316
|
-
if (override === true) {
|
|
317
|
-
processEnv[key] = parsed[key];
|
|
318
|
-
populated[key] = parsed[key];
|
|
319
|
-
}
|
|
320
|
-
if (debug) {
|
|
321
|
-
if (override === true) {
|
|
322
|
-
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
323
|
-
} else {
|
|
324
|
-
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
} else {
|
|
328
|
-
processEnv[key] = parsed[key];
|
|
329
|
-
populated[key] = parsed[key];
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return populated;
|
|
333
|
-
}
|
|
334
|
-
var DotenvModule = {
|
|
335
|
-
configDotenv,
|
|
336
|
-
_configVault,
|
|
337
|
-
_parseVault,
|
|
338
|
-
config,
|
|
339
|
-
decrypt,
|
|
340
|
-
parse,
|
|
341
|
-
populate
|
|
342
|
-
};
|
|
343
|
-
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
344
|
-
module.exports._configVault = DotenvModule._configVault;
|
|
345
|
-
module.exports._parseVault = DotenvModule._parseVault;
|
|
346
|
-
module.exports.config = DotenvModule.config;
|
|
347
|
-
module.exports.decrypt = DotenvModule.decrypt;
|
|
348
|
-
module.exports.parse = DotenvModule.parse;
|
|
349
|
-
module.exports.populate = DotenvModule.populate;
|
|
350
|
-
module.exports = DotenvModule;
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// ../config/dist/index.js
|
|
355
|
-
var require_dist = __commonJS({
|
|
356
|
-
"../config/dist/index.js"(exports, module) {
|
|
357
|
-
"use strict";
|
|
358
|
-
var __create2 = Object.create;
|
|
359
|
-
var __defProp2 = Object.defineProperty;
|
|
360
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
361
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
362
|
-
var __getProtoOf2 = Object.getPrototypeOf;
|
|
363
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
364
|
-
var __export = (target, all) => {
|
|
365
|
-
for (var name in all)
|
|
366
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
367
|
-
};
|
|
368
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
369
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
370
|
-
for (let key of __getOwnPropNames2(from))
|
|
371
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
372
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
373
|
-
}
|
|
374
|
-
return to;
|
|
375
|
-
};
|
|
376
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
377
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
378
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
379
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
380
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
381
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
382
|
-
mod
|
|
383
|
-
));
|
|
384
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
385
|
-
var index_exports = {};
|
|
386
|
-
__export(index_exports, {
|
|
387
|
-
env: () => env
|
|
388
|
-
});
|
|
389
|
-
module.exports = __toCommonJS(index_exports);
|
|
390
|
-
var import_dotenv = __toESM2(require_main());
|
|
391
|
-
import_dotenv.default.config();
|
|
392
|
-
var env = {
|
|
393
|
-
openRouterKey: process.env.OPENROUTER_API_KEY
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
});
|
|
2
|
+
import {
|
|
3
|
+
__commonJS,
|
|
4
|
+
__require,
|
|
5
|
+
__toESM,
|
|
6
|
+
require_dist
|
|
7
|
+
} from "./chunk-4ANZDGVD.js";
|
|
397
8
|
|
|
398
9
|
// ../analyzers/dist/index.js
|
|
399
10
|
var require_dist2 = __commonJS({
|
|
400
11
|
"../analyzers/dist/index.js"(exports, module) {
|
|
401
12
|
"use strict";
|
|
402
|
-
var
|
|
403
|
-
var
|
|
404
|
-
var
|
|
405
|
-
var
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
406
17
|
var __export = (target, all) => {
|
|
407
18
|
for (var name in all)
|
|
408
|
-
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
409
20
|
};
|
|
410
|
-
var
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
411
22
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
412
|
-
for (let key of
|
|
413
|
-
if (!
|
|
414
|
-
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
415
26
|
}
|
|
416
27
|
return to;
|
|
417
28
|
};
|
|
418
|
-
var __toCommonJS = (mod) =>
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
419
30
|
var index_exports = {};
|
|
420
31
|
__export(index_exports, {
|
|
421
32
|
parseErrors: () => parseErrors,
|
|
@@ -503,60 +114,94 @@ var require_dist2 = __commonJS({
|
|
|
503
114
|
var require_dist3 = __commonJS({
|
|
504
115
|
"../ai-provider/dist/index.js"(exports, module) {
|
|
505
116
|
"use strict";
|
|
506
|
-
var
|
|
507
|
-
var
|
|
508
|
-
var
|
|
509
|
-
var
|
|
510
|
-
var
|
|
511
|
-
var
|
|
117
|
+
var __create = Object.create;
|
|
118
|
+
var __defProp = Object.defineProperty;
|
|
119
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
120
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
121
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
122
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
512
123
|
var __export = (target, all) => {
|
|
513
124
|
for (var name in all)
|
|
514
|
-
|
|
125
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
515
126
|
};
|
|
516
|
-
var
|
|
127
|
+
var __copyProps = (to, from, except, desc) => {
|
|
517
128
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
518
|
-
for (let key of
|
|
519
|
-
if (!
|
|
520
|
-
|
|
129
|
+
for (let key of __getOwnPropNames(from))
|
|
130
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
131
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
521
132
|
}
|
|
522
133
|
return to;
|
|
523
134
|
};
|
|
524
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ?
|
|
135
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
525
136
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
526
137
|
// file that has been converted to a CommonJS file using a Babel-
|
|
527
138
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
528
139
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
529
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
140
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
530
141
|
mod
|
|
531
142
|
));
|
|
532
|
-
var __toCommonJS = (mod) =>
|
|
143
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
533
144
|
var index_exports = {};
|
|
534
145
|
__export(index_exports, {
|
|
535
146
|
OpenRouterProvider: () => OpenRouterProvider
|
|
536
147
|
});
|
|
537
148
|
module.exports = __toCommonJS(index_exports);
|
|
538
149
|
var import_axios = __toESM2(__require("axios"));
|
|
150
|
+
var import_fs = __toESM2(__require("fs"));
|
|
151
|
+
var import_path2 = __toESM2(__require("path"));
|
|
152
|
+
function resolveModel(cwd) {
|
|
153
|
+
try {
|
|
154
|
+
const configPath = import_path2.default.resolve(cwd ?? process.cwd(), ".bugzerorc");
|
|
155
|
+
if (import_fs.default.existsSync(configPath)) {
|
|
156
|
+
const config = JSON.parse(import_fs.default.readFileSync(configPath, "utf-8"));
|
|
157
|
+
if (config.model) return config.model;
|
|
158
|
+
}
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
return "deepseek/deepseek-chat";
|
|
162
|
+
}
|
|
539
163
|
var OpenRouterProvider = class {
|
|
540
|
-
async invoke(prompt) {
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
164
|
+
async invoke(prompt, options) {
|
|
165
|
+
const model = resolveModel(options?.cwd);
|
|
166
|
+
try {
|
|
167
|
+
const response = await import_axios.default.post(
|
|
168
|
+
"https://openrouter.ai/api/v1/chat/completions",
|
|
169
|
+
{
|
|
170
|
+
model,
|
|
171
|
+
messages: [
|
|
172
|
+
{
|
|
173
|
+
role: "user",
|
|
174
|
+
content: prompt
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
headers: {
|
|
180
|
+
Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
|
|
181
|
+
"Content-Type": "application/json"
|
|
549
182
|
}
|
|
550
|
-
]
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
headers: {
|
|
554
|
-
Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
|
|
555
|
-
"Content-Type": "application/json"
|
|
556
183
|
}
|
|
184
|
+
);
|
|
185
|
+
if (response.data?.error) {
|
|
186
|
+
throw new Error(response.data.error.message || JSON.stringify(response.data.error));
|
|
557
187
|
}
|
|
558
|
-
|
|
559
|
-
|
|
188
|
+
return response.data.choices[0].message.content;
|
|
189
|
+
} catch (error) {
|
|
190
|
+
let msg = error.message;
|
|
191
|
+
if (error.response?.data?.error?.message) {
|
|
192
|
+
msg = error.response.data.error.message;
|
|
193
|
+
} else if (error.response?.data?.message) {
|
|
194
|
+
msg = error.response.data.message;
|
|
195
|
+
}
|
|
196
|
+
console.error(`
|
|
197
|
+
\u274C [BugZero] OpenRouter API Error: ${msg}`);
|
|
198
|
+
if (error.response?.status === 401) {
|
|
199
|
+
console.error(`\u{1F449} Please check if your OPENROUTER_API_KEY is correct and active.`);
|
|
200
|
+
} else if (error.response?.status === 429) {
|
|
201
|
+
console.error(`\u{1F449} Rate limit exceeded or insufficient credits. Please check your OpenRouter balance.`);
|
|
202
|
+
}
|
|
203
|
+
throw new Error(`OpenRouter API failed: ${msg}`);
|
|
204
|
+
}
|
|
560
205
|
}
|
|
561
206
|
};
|
|
562
207
|
}
|
|
@@ -566,23 +211,23 @@ var require_dist3 = __commonJS({
|
|
|
566
211
|
var require_dist4 = __commonJS({
|
|
567
212
|
"../prompts/dist/index.js"(exports, module) {
|
|
568
213
|
"use strict";
|
|
569
|
-
var
|
|
570
|
-
var
|
|
571
|
-
var
|
|
572
|
-
var
|
|
214
|
+
var __defProp = Object.defineProperty;
|
|
215
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
216
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
217
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
573
218
|
var __export = (target, all) => {
|
|
574
219
|
for (var name in all)
|
|
575
|
-
|
|
220
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
576
221
|
};
|
|
577
|
-
var
|
|
222
|
+
var __copyProps = (to, from, except, desc) => {
|
|
578
223
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
579
|
-
for (let key of
|
|
580
|
-
if (!
|
|
581
|
-
|
|
224
|
+
for (let key of __getOwnPropNames(from))
|
|
225
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
226
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
582
227
|
}
|
|
583
228
|
return to;
|
|
584
229
|
};
|
|
585
|
-
var __toCommonJS = (mod) =>
|
|
230
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
586
231
|
var index_exports = {};
|
|
587
232
|
__export(index_exports, {
|
|
588
233
|
buildAnalysisPrompt: () => buildAnalysisPrompt
|
|
@@ -624,33 +269,33 @@ Critical rules:
|
|
|
624
269
|
var require_dist5 = __commonJS({
|
|
625
270
|
"../patcher/dist/index.js"(exports, module) {
|
|
626
271
|
"use strict";
|
|
627
|
-
var
|
|
628
|
-
var
|
|
629
|
-
var
|
|
630
|
-
var
|
|
631
|
-
var
|
|
632
|
-
var
|
|
272
|
+
var __create = Object.create;
|
|
273
|
+
var __defProp = Object.defineProperty;
|
|
274
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
275
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
276
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
277
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
633
278
|
var __export = (target, all) => {
|
|
634
279
|
for (var name in all)
|
|
635
|
-
|
|
280
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
636
281
|
};
|
|
637
|
-
var
|
|
282
|
+
var __copyProps = (to, from, except, desc) => {
|
|
638
283
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
639
|
-
for (let key of
|
|
640
|
-
if (!
|
|
641
|
-
|
|
284
|
+
for (let key of __getOwnPropNames(from))
|
|
285
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
286
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
642
287
|
}
|
|
643
288
|
return to;
|
|
644
289
|
};
|
|
645
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ?
|
|
290
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
646
291
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
647
292
|
// file that has been converted to a CommonJS file using a Babel-
|
|
648
293
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
649
294
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
650
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
295
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
651
296
|
mod
|
|
652
297
|
));
|
|
653
|
-
var __toCommonJS = (mod) =>
|
|
298
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
654
299
|
var index_exports = {};
|
|
655
300
|
__export(index_exports, {
|
|
656
301
|
applyPatch: () => applyPatch
|
|
@@ -689,33 +334,33 @@ var require_dist5 = __commonJS({
|
|
|
689
334
|
var require_dist6 = __commonJS({
|
|
690
335
|
"../agents/dist/index.js"(exports, module) {
|
|
691
336
|
"use strict";
|
|
692
|
-
var
|
|
693
|
-
var
|
|
694
|
-
var
|
|
695
|
-
var
|
|
696
|
-
var
|
|
697
|
-
var
|
|
337
|
+
var __create = Object.create;
|
|
338
|
+
var __defProp = Object.defineProperty;
|
|
339
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
340
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
341
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
342
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
698
343
|
var __export = (target, all) => {
|
|
699
344
|
for (var name in all)
|
|
700
|
-
|
|
345
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
701
346
|
};
|
|
702
|
-
var
|
|
347
|
+
var __copyProps = (to, from, except, desc) => {
|
|
703
348
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
704
|
-
for (let key of
|
|
705
|
-
if (!
|
|
706
|
-
|
|
349
|
+
for (let key of __getOwnPropNames(from))
|
|
350
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
351
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
707
352
|
}
|
|
708
353
|
return to;
|
|
709
354
|
};
|
|
710
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ?
|
|
355
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
711
356
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
712
357
|
// file that has been converted to a CommonJS file using a Babel-
|
|
713
358
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
714
359
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
715
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
360
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
716
361
|
mod
|
|
717
362
|
));
|
|
718
|
-
var __toCommonJS = (mod) =>
|
|
363
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
719
364
|
var index_exports = {};
|
|
720
365
|
__export(index_exports, {
|
|
721
366
|
workflow: () => workflow
|
|
@@ -769,10 +414,10 @@ var require_dist6 = __commonJS({
|
|
|
769
414
|
async function analyzeNode(state) {
|
|
770
415
|
console.log(
|
|
771
416
|
`
|
|
772
|
-
[
|
|
417
|
+
[BugZero] Attempt ${state.attempts + 1}/${state.maxAttempts} \u2014 asking AI\u2026`
|
|
773
418
|
);
|
|
774
419
|
const prompt = (0, import_prompts.buildAnalysisPrompt)(state.logs, state.cwd);
|
|
775
|
-
const response = await provider.invoke(prompt);
|
|
420
|
+
const response = await provider.invoke(prompt, { cwd: state.cwd });
|
|
776
421
|
let fixSuggestion = null;
|
|
777
422
|
try {
|
|
778
423
|
const cleaned = response.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
|
|
@@ -780,10 +425,10 @@ var require_dist6 = __commonJS({
|
|
|
780
425
|
if (jsonMatch) {
|
|
781
426
|
fixSuggestion = JSON.parse(jsonMatch[0]);
|
|
782
427
|
} else {
|
|
783
|
-
console.warn("[
|
|
428
|
+
console.warn("[BugZero] AI response did not contain a valid JSON object.");
|
|
784
429
|
}
|
|
785
430
|
} catch (e) {
|
|
786
|
-
console.error("[
|
|
431
|
+
console.error("[BugZero] Failed to parse AI response:", e);
|
|
787
432
|
}
|
|
788
433
|
return {
|
|
789
434
|
analysis: response,
|
|
@@ -793,28 +438,28 @@ var require_dist6 = __commonJS({
|
|
|
793
438
|
}
|
|
794
439
|
async function applyFixNode(state) {
|
|
795
440
|
if (!state.fixSuggestion) {
|
|
796
|
-
console.warn("[
|
|
441
|
+
console.warn("[BugZero] No fix suggestion available \u2014 skipping patch.");
|
|
797
442
|
return {};
|
|
798
443
|
}
|
|
799
444
|
const { filePath, search, replace, explanation } = state.fixSuggestion;
|
|
800
445
|
const absolutePath = import_path2.default.resolve(state.cwd, filePath);
|
|
801
|
-
console.log(`[
|
|
802
|
-
console.log(`[
|
|
446
|
+
console.log(`[BugZero] Patching: ${filePath}`);
|
|
447
|
+
console.log(`[BugZero] Reason: ${explanation}`);
|
|
803
448
|
const result = (0, import_patcher.applyPatch)(absolutePath, search, replace);
|
|
804
449
|
if (!result.success) {
|
|
805
|
-
console.error(`[
|
|
450
|
+
console.error(`[BugZero] Patch failed: ${result.error}`);
|
|
806
451
|
} else {
|
|
807
|
-
console.log(`[
|
|
452
|
+
console.log(`[BugZero] Backup saved to: ${result.backupPath}`);
|
|
808
453
|
}
|
|
809
454
|
return {};
|
|
810
455
|
}
|
|
811
456
|
async function verifyNode(state) {
|
|
812
|
-
console.log("[
|
|
457
|
+
console.log("[BugZero] Re-running build to verify fix\u2026");
|
|
813
458
|
const result = await (0, import_analyzers.runBuild)(state.cwd);
|
|
814
459
|
if (result.success) {
|
|
815
|
-
console.log("[
|
|
460
|
+
console.log("[BugZero] \u2705 Build succeeded!");
|
|
816
461
|
} else {
|
|
817
|
-
console.log("[
|
|
462
|
+
console.log("[BugZero] \u274C Build still failing. New error output captured.");
|
|
818
463
|
}
|
|
819
464
|
return {
|
|
820
465
|
success: result.success,
|
|
@@ -825,7 +470,7 @@ var require_dist6 = __commonJS({
|
|
|
825
470
|
if (state.success) return import_langgraph2.END;
|
|
826
471
|
if (state.attempts >= state.maxAttempts) {
|
|
827
472
|
console.log(
|
|
828
|
-
`[
|
|
473
|
+
`[BugZero] Max attempts (${state.maxAttempts}) reached \u2014 giving up.`
|
|
829
474
|
);
|
|
830
475
|
return import_langgraph2.END;
|
|
831
476
|
}
|
|
@@ -839,33 +484,33 @@ var require_dist6 = __commonJS({
|
|
|
839
484
|
var require_dist7 = __commonJS({
|
|
840
485
|
"../core/dist/index.js"(exports, module) {
|
|
841
486
|
"use strict";
|
|
842
|
-
var
|
|
843
|
-
var
|
|
844
|
-
var
|
|
845
|
-
var
|
|
846
|
-
var
|
|
847
|
-
var
|
|
487
|
+
var __create = Object.create;
|
|
488
|
+
var __defProp = Object.defineProperty;
|
|
489
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
490
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
491
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
492
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
848
493
|
var __export = (target, all) => {
|
|
849
494
|
for (var name in all)
|
|
850
|
-
|
|
495
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
851
496
|
};
|
|
852
|
-
var
|
|
497
|
+
var __copyProps = (to, from, except, desc) => {
|
|
853
498
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
854
|
-
for (let key of
|
|
855
|
-
if (!
|
|
856
|
-
|
|
499
|
+
for (let key of __getOwnPropNames(from))
|
|
500
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
501
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
857
502
|
}
|
|
858
503
|
return to;
|
|
859
504
|
};
|
|
860
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ?
|
|
505
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
861
506
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
862
507
|
// file that has been converted to a CommonJS file using a Babel-
|
|
863
508
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
864
509
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
865
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
510
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
866
511
|
mod
|
|
867
512
|
));
|
|
868
|
-
var __toCommonJS = (mod) =>
|
|
513
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
869
514
|
var index_exports = {};
|
|
870
515
|
__export(index_exports, {
|
|
871
516
|
detectFramework: () => detectFramework2,
|
|
@@ -914,16 +559,16 @@ var require_dist7 = __commonJS({
|
|
|
914
559
|
async function orchestrateAndFix2(options = {}) {
|
|
915
560
|
const cwd = options.cwd ?? process.cwd();
|
|
916
561
|
const maxAttempts = options.maxAttempts ?? 3;
|
|
917
|
-
console.log(`[
|
|
562
|
+
console.log(`[BugZero] Running build in: ${cwd}`);
|
|
918
563
|
const buildResult = await (0, import_analyzers.runBuild)(cwd);
|
|
919
564
|
if (buildResult.success) {
|
|
920
|
-
console.log("[
|
|
565
|
+
console.log("[BugZero] Build already passing \u2014 nothing to fix.");
|
|
921
566
|
return { success: true, attempts: 0, finalOutput: buildResult.output };
|
|
922
567
|
}
|
|
923
568
|
const errors = (0, import_analyzers.parseErrors)(buildResult.output);
|
|
924
|
-
console.log(`[
|
|
569
|
+
console.log(`[BugZero] Detected ${errors.length} error(s) (type: ${errors[0]?.type ?? "unknown"})`);
|
|
925
570
|
if (options.dryRun) {
|
|
926
|
-
console.log("[
|
|
571
|
+
console.log("[BugZero] Dry-run mode \u2014 skipping AI fix.");
|
|
927
572
|
return {
|
|
928
573
|
success: false,
|
|
929
574
|
attempts: 0,
|
|
@@ -956,7 +601,7 @@ import { Command } from "commander";
|
|
|
956
601
|
import path from "path";
|
|
957
602
|
var program = new Command();
|
|
958
603
|
program.name("bugzero").description("AI-powered build issue fixer \u2014 detects and repairs build errors automatically").version("0.0.1");
|
|
959
|
-
program.command("
|
|
604
|
+
program.command("hunt").description("Run build, lint, and tests \u2014 report issues without modifying files").option("-p, --path <dir>", "Path to the target project", ".").action(async (opts) => {
|
|
960
605
|
const cwd = path.resolve(opts.path);
|
|
961
606
|
const framework = (0, import_core.detectFramework)(cwd);
|
|
962
607
|
console.log(`
|
|
@@ -988,11 +633,11 @@ program.command("analyze").description("Run build, lint, and tests \u2014 report
|
|
|
988
633
|
}
|
|
989
634
|
const allPassed = build.success && lint.success && test.success;
|
|
990
635
|
console.log(`
|
|
991
|
-
${allPassed ? "\u2705 All checks passed" : "\u274C Issues found \u2014 run 'bugzero
|
|
636
|
+
${allPassed ? "\u2705 All checks passed" : "\u274C Issues found \u2014 run 'bugzero rescue' to repair"}
|
|
992
637
|
`);
|
|
993
638
|
process.exit(allPassed ? 0 : 1);
|
|
994
639
|
});
|
|
995
|
-
program.command("
|
|
640
|
+
program.command("rescue").description("Detect build failures and automatically apply AI-generated fixes").option("-p, --path <dir>", "Path to the target project", ".").option("-n, --max-attempts <number>", "Maximum AI fix attempts", "3").option("--dry-run", "Analyse only \u2014 print what would be fixed without writing files", false).action(async (opts) => {
|
|
996
641
|
const cwd = path.resolve(opts.path);
|
|
997
642
|
const maxAttempts = parseInt(opts.maxAttempts, 10);
|
|
998
643
|
const dryRun = opts.dryRun;
|
|
@@ -1020,9 +665,88 @@ program.command("fix").description("Detect build failures and automatically appl
|
|
|
1020
665
|
console.log();
|
|
1021
666
|
process.exit(result.success ? 0 : 1);
|
|
1022
667
|
});
|
|
1023
|
-
program.command("protect").description("[Deprecated] Use '
|
|
1024
|
-
console.warn("\u26A0\uFE0F 'protect' is deprecated \u2014 use 'bugzero
|
|
668
|
+
program.command("protect").description("[Deprecated] Use 'hunt' instead").action(async () => {
|
|
669
|
+
console.warn("\u26A0\uFE0F 'protect' is deprecated \u2014 use 'bugzero hunt' instead.\n");
|
|
1025
670
|
const result = await (0, import_core.orchestrate)();
|
|
1026
671
|
console.log(result);
|
|
1027
672
|
});
|
|
673
|
+
program.command("vibe").description("Select which AI model (brain) to use for resolving bugs").action(async () => {
|
|
674
|
+
const { getLocalConfig, saveLocalConfig } = await import("./dist-FQYNA36C.js");
|
|
675
|
+
const readline = await import("readline");
|
|
676
|
+
const axios = (await import("axios")).default;
|
|
677
|
+
console.log(`
|
|
678
|
+
\u{1F9E0} BugZero Brain Selector`);
|
|
679
|
+
console.log(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
680
|
+
let popularModels = [];
|
|
681
|
+
try {
|
|
682
|
+
console.log("\u{1F300} Fetching active models list from OpenRouter...");
|
|
683
|
+
const response = await axios.get("https://openrouter.ai/api/v1/models", { timeout: 8e3 });
|
|
684
|
+
const allModels = response.data?.data || [];
|
|
685
|
+
const popularModelIds = [
|
|
686
|
+
"deepseek/deepseek-chat",
|
|
687
|
+
"deepseek/deepseek-r1",
|
|
688
|
+
"anthropic/claude-3.5-sonnet",
|
|
689
|
+
"google/gemini-2.5-pro",
|
|
690
|
+
"google/gemini-2.5-flash",
|
|
691
|
+
"openai/gpt-4o",
|
|
692
|
+
"meta-llama/llama-3.3-70b-instruct"
|
|
693
|
+
];
|
|
694
|
+
popularModels = allModels.filter((m) => popularModelIds.includes(m.id));
|
|
695
|
+
} catch (e) {
|
|
696
|
+
console.warn("\u26A0\uFE0F Failed to fetch models list from OpenRouter. Using cached default list.");
|
|
697
|
+
}
|
|
698
|
+
if (popularModels.length === 0) {
|
|
699
|
+
popularModels = [
|
|
700
|
+
{ id: "deepseek/deepseek-chat", name: "DeepSeek V3 (Chat)" },
|
|
701
|
+
{ id: "deepseek/deepseek-r1", name: "DeepSeek R1" },
|
|
702
|
+
{ id: "anthropic/claude-3.5-sonnet", name: "Claude 3.5 Sonnet" },
|
|
703
|
+
{ id: "google/gemini-2.5-pro", name: "Gemini 2.5 Pro" },
|
|
704
|
+
{ id: "google/gemini-2.5-flash", name: "Gemini 2.5 Flash" },
|
|
705
|
+
{ id: "openai/gpt-4o", name: "GPT-4o" },
|
|
706
|
+
{ id: "meta-llama/llama-3.3-70b-instruct", name: "Llama 3.3 Instruct" }
|
|
707
|
+
];
|
|
708
|
+
}
|
|
709
|
+
const currentModel = getLocalConfig().model || "deepseek/deepseek-chat";
|
|
710
|
+
console.log(`
|
|
711
|
+
Current active model: \x1B[36m${currentModel}\x1B[0m
|
|
712
|
+
`);
|
|
713
|
+
popularModels.forEach((m, idx) => {
|
|
714
|
+
console.log(` [${idx + 1}] ${m.name} (${m.id})`);
|
|
715
|
+
});
|
|
716
|
+
console.log(` [${popularModels.length + 1}] \u{1F58B}\uFE0F Custom Model (Type manually)`);
|
|
717
|
+
console.log();
|
|
718
|
+
const rl = readline.createInterface({
|
|
719
|
+
input: process.stdin,
|
|
720
|
+
output: process.stdout
|
|
721
|
+
});
|
|
722
|
+
rl.question(`Select a number (1-${popularModels.length + 1}): `, (answer) => {
|
|
723
|
+
const choice = parseInt(answer.trim(), 10);
|
|
724
|
+
if (isNaN(choice) || choice < 1 || choice > popularModels.length + 1) {
|
|
725
|
+
console.log("\u274C Invalid selection. Keeping current model.");
|
|
726
|
+
rl.close();
|
|
727
|
+
process.exit(1);
|
|
728
|
+
}
|
|
729
|
+
if (choice === popularModels.length + 1) {
|
|
730
|
+
rl.question("Enter custom OpenRouter Model ID (e.g. microsoft/phi-3-medium-128k-instruct): ", (customModel) => {
|
|
731
|
+
const selected = customModel.trim();
|
|
732
|
+
if (!selected) {
|
|
733
|
+
console.log("\u274C No model entered. Keeping current model.");
|
|
734
|
+
} else {
|
|
735
|
+
saveLocalConfig({ model: selected });
|
|
736
|
+
console.log(`
|
|
737
|
+
\u2705 Saved! Model set to: \x1B[32m${selected}\x1B[0m`);
|
|
738
|
+
console.log(` Saved config to: .bugzerorc`);
|
|
739
|
+
}
|
|
740
|
+
rl.close();
|
|
741
|
+
});
|
|
742
|
+
} else {
|
|
743
|
+
const selected = popularModels[choice - 1].id;
|
|
744
|
+
saveLocalConfig({ model: selected });
|
|
745
|
+
console.log(`
|
|
746
|
+
\u2705 Saved! Model set to: \x1B[32m${selected}\x1B[0m`);
|
|
747
|
+
console.log(` Saved config to: .bugzerorc`);
|
|
748
|
+
rl.close();
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
});
|
|
1028
752
|
program.parse();
|