bugzero 0.0.26 → 0.0.28
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 +4 -4
- package/dist/index.js +98 -56
- package/package.json +2 -1
- package/src/index.ts +64 -54
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> bugzero@0.0.
|
|
2
|
+
> bugzero@0.0.28 build D:\WD projects\OpsPilot\packages\cli
|
|
3
3
|
> tsup src/index.ts --format cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
[34mCLI[39m tsup v8.5.1
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist\index.js [22m[
|
|
11
|
-
[32mCJS[39m ⚡️ Build success in
|
|
10
|
+
[32mCJS[39m [1mdist\index.js [22m[32m70.42 KB[39m
|
|
11
|
+
[32mCJS[39m ⚡️ Build success in 111ms
|
|
12
12
|
[34mDTS[39m Build start
|
|
13
|
-
[32mDTS[39m ⚡️ Build success in
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 2699ms
|
|
14
14
|
[32mDTS[39m [1mdist\index.d.ts [22m[32m20.00 B[39m
|
package/dist/index.js
CHANGED
|
@@ -386,18 +386,36 @@ var require_dist = __commonJS({
|
|
|
386
386
|
});
|
|
387
387
|
module2.exports = __toCommonJS(index_exports);
|
|
388
388
|
var import_dotenv = __toESM2(require_main());
|
|
389
|
-
import_dotenv.default.config();
|
|
390
|
-
var env = {
|
|
391
|
-
openRouterKey: process.env.OPENROUTER_API_KEY
|
|
392
|
-
};
|
|
393
389
|
var import_fs = __toESM2(require("fs"));
|
|
394
390
|
var import_path2 = __toESM2(require("path"));
|
|
391
|
+
function loadEnv() {
|
|
392
|
+
let dir = process.cwd();
|
|
393
|
+
while (true) {
|
|
394
|
+
const envPath = import_path2.default.join(dir, ".env");
|
|
395
|
+
if (import_fs.default.existsSync(envPath)) {
|
|
396
|
+
import_dotenv.default.config({ path: envPath });
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const parent = import_path2.default.dirname(dir);
|
|
400
|
+
if (parent === dir) {
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
dir = parent;
|
|
404
|
+
}
|
|
405
|
+
import_dotenv.default.config();
|
|
406
|
+
}
|
|
407
|
+
loadEnv();
|
|
408
|
+
var env = {
|
|
409
|
+
openRouterKey: process.env.OPENROUTER_API_KEY || ""
|
|
410
|
+
};
|
|
411
|
+
var import_fs2 = __toESM2(require("fs"));
|
|
412
|
+
var import_path22 = __toESM2(require("path"));
|
|
395
413
|
var CONFIG_FILENAME = ".bugzerorc";
|
|
396
414
|
function getLocalConfig(cwd = process.cwd()) {
|
|
397
415
|
try {
|
|
398
|
-
const configPath =
|
|
399
|
-
if (
|
|
400
|
-
const content =
|
|
416
|
+
const configPath = import_path22.default.resolve(cwd, CONFIG_FILENAME);
|
|
417
|
+
if (import_fs2.default.existsSync(configPath)) {
|
|
418
|
+
const content = import_fs2.default.readFileSync(configPath, "utf-8");
|
|
401
419
|
return JSON.parse(content);
|
|
402
420
|
}
|
|
403
421
|
} catch (e) {
|
|
@@ -405,8 +423,8 @@ var require_dist = __commonJS({
|
|
|
405
423
|
return {};
|
|
406
424
|
}
|
|
407
425
|
function saveLocalConfig(config, cwd = process.cwd()) {
|
|
408
|
-
const configPath =
|
|
409
|
-
|
|
426
|
+
const configPath = import_path22.default.resolve(cwd, CONFIG_FILENAME);
|
|
427
|
+
import_fs2.default.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
410
428
|
}
|
|
411
429
|
function getSelectedModel(cwd = process.cwd()) {
|
|
412
430
|
const config = getLocalConfig(cwd);
|
|
@@ -621,6 +639,18 @@ var require_dist3 = __commonJS({
|
|
|
621
639
|
var OpenRouterProvider = class {
|
|
622
640
|
async invoke(prompt, options) {
|
|
623
641
|
const model = resolveModel(options?.cwd);
|
|
642
|
+
const apiKey = process.env.OPENROUTER_API_KEY;
|
|
643
|
+
if (!apiKey) {
|
|
644
|
+
console.error(`
|
|
645
|
+
\u274C [BugZero] Error: OPENROUTER_API_KEY environment variable is not set.`);
|
|
646
|
+
console.error(`\u{1F449} Please configure it using one of the following methods:`);
|
|
647
|
+
console.error(` - On macOS/Linux: export OPENROUTER_API_KEY="your_openrouter_api_key_here"`);
|
|
648
|
+
console.error(` - On Windows (PowerShell): $env:OPENROUTER_API_KEY="your_openrouter_api_key_here"`);
|
|
649
|
+
console.error(` - Or add it to a .env file at the root of the project you are fixing:`);
|
|
650
|
+
console.error(` OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
651
|
+
`);
|
|
652
|
+
throw new Error("Missing OPENROUTER_API_KEY environment variable.");
|
|
653
|
+
}
|
|
624
654
|
try {
|
|
625
655
|
const response = await import_axios.default.post(
|
|
626
656
|
"https://openrouter.ai/api/v1/chat/completions",
|
|
@@ -1511,62 +1541,74 @@ var import_core = __toESM(require_dist7());
|
|
|
1511
1541
|
var program = new import_commander.Command();
|
|
1512
1542
|
program.name("bugzero").description("AI-powered build issue fixer \u2014 detects and repairs build errors automatically").version("0.0.1");
|
|
1513
1543
|
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) => {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1544
|
+
try {
|
|
1545
|
+
const cwd = import_path.default.resolve(opts.path);
|
|
1546
|
+
const framework = (0, import_core.detectFramework)(cwd);
|
|
1547
|
+
console.log(`
|
|
1517
1548
|
\u{1F50D} BugZero \u2014 Analyzing project`);
|
|
1518
|
-
|
|
1519
|
-
|
|
1549
|
+
console.log(` Path: ${cwd}`);
|
|
1550
|
+
console.log(` Framework: ${framework}
|
|
1520
1551
|
`);
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1552
|
+
const { build, lint, test } = await (0, import_core.orchestrate)({ cwd });
|
|
1553
|
+
console.log("\u2500\u2500 Pipeline Summary \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");
|
|
1554
|
+
console.log(` Build: ${build.success ? "\u2705 Passed" : "\u274C Failed (see report)"}`);
|
|
1555
|
+
console.log(` Lint: ${lint.success ? "\u2705 Passed" : "\u274C Failed (see report)"}`);
|
|
1556
|
+
console.log(` Tests: ${test.success ? "\u2705 Passed" : "\u274C Failed (see report)"}`);
|
|
1557
|
+
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\u2500");
|
|
1558
|
+
const allPassed = build.success && lint.success && test.success;
|
|
1559
|
+
console.log(`
|
|
1529
1560
|
${allPassed ? "\u2705 All checks passed" : "\u274C Issues found \u2014 run 'bugzero rescue' to repair"}
|
|
1530
1561
|
`);
|
|
1531
|
-
|
|
1562
|
+
process.exit(allPassed ? 0 : 1);
|
|
1563
|
+
} catch (error) {
|
|
1564
|
+
console.error(`
|
|
1565
|
+
\u274C [BugZero] Execution failed: ${error.message || error}`);
|
|
1566
|
+
process.exit(1);
|
|
1567
|
+
}
|
|
1532
1568
|
});
|
|
1533
1569
|
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) => {
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
\u{1F916} BugZero Fix`);
|
|
1540
|
-
console.log(` Path: ${cwd}`);
|
|
1541
|
-
console.log(` Framework: ${framework}`);
|
|
1542
|
-
console.log(` Max attempts: ${maxAttempts}`);
|
|
1543
|
-
if (dryRun) console.log(` Mode: DRY RUN (no files will be modified)`);
|
|
1544
|
-
console.log();
|
|
1545
|
-
const result = await (0, import_core.orchestrateAndFix)({ cwd, maxAttempts, dryRun });
|
|
1546
|
-
console.log("\n\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");
|
|
1547
|
-
if (result.success) {
|
|
1548
|
-
console.log(`\u2705 Build fixed after ${result.attempts} attempt(s)!`);
|
|
1549
|
-
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1550
|
-
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1551
|
-
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1552
|
-
}
|
|
1553
|
-
if (result.appliedFix) {
|
|
1554
|
-
console.log(` File: ${result.appliedFix.filePath}`);
|
|
1555
|
-
console.log(` Reason: ${result.appliedFix.explanation}`);
|
|
1556
|
-
console.log(` Root cause: ${result.appliedFix.rootCause}`);
|
|
1557
|
-
}
|
|
1558
|
-
} else {
|
|
1559
|
-
console.log(`\u274C Could not fix build after ${result.attempts} attempt(s).`);
|
|
1560
|
-
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1561
|
-
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1562
|
-
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1563
|
-
}
|
|
1564
|
-
if (result.error) console.log(` ${result.error}`);
|
|
1570
|
+
try {
|
|
1571
|
+
const cwd = import_path.default.resolve(opts.path);
|
|
1572
|
+
const maxAttempts = parseInt(opts.maxAttempts, 10);
|
|
1573
|
+
const dryRun = opts.dryRun;
|
|
1574
|
+
const framework = (0, import_core.detectFramework)(cwd);
|
|
1565
1575
|
console.log(`
|
|
1576
|
+
\u{1F916} BugZero Fix`);
|
|
1577
|
+
console.log(` Path: ${cwd}`);
|
|
1578
|
+
console.log(` Framework: ${framework}`);
|
|
1579
|
+
console.log(` Max attempts: ${maxAttempts}`);
|
|
1580
|
+
if (dryRun) console.log(` Mode: DRY RUN (no files will be modified)`);
|
|
1581
|
+
console.log();
|
|
1582
|
+
const result = await (0, import_core.orchestrateAndFix)({ cwd, maxAttempts, dryRun });
|
|
1583
|
+
console.log("\n\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");
|
|
1584
|
+
if (result.success) {
|
|
1585
|
+
console.log(`\u2705 Build fixed after ${result.attempts} attempt(s)!`);
|
|
1586
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1587
|
+
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1588
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1589
|
+
}
|
|
1590
|
+
if (result.appliedFix) {
|
|
1591
|
+
console.log(` File: ${result.appliedFix.filePath}`);
|
|
1592
|
+
console.log(` Reason: ${result.appliedFix.explanation}`);
|
|
1593
|
+
console.log(` Root cause: ${result.appliedFix.rootCause}`);
|
|
1594
|
+
}
|
|
1595
|
+
} else {
|
|
1596
|
+
console.log(`\u274C Could not fix build after ${result.attempts} attempt(s).`);
|
|
1597
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1598
|
+
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1599
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1600
|
+
}
|
|
1601
|
+
if (result.error) console.log(` ${result.error}`);
|
|
1602
|
+
console.log(`
|
|
1566
1603
|
\u{1F449} Full unresolved error logs have been listed in the generated report.`);
|
|
1604
|
+
}
|
|
1605
|
+
console.log();
|
|
1606
|
+
process.exit(result.success ? 0 : 1);
|
|
1607
|
+
} catch (error) {
|
|
1608
|
+
console.error(`
|
|
1609
|
+
\u274C [BugZero] Execution failed: ${error.message || error}`);
|
|
1610
|
+
process.exit(1);
|
|
1567
1611
|
}
|
|
1568
|
-
console.log();
|
|
1569
|
-
process.exit(result.success ? 0 : 1);
|
|
1570
1612
|
});
|
|
1571
1613
|
program.command("protect").description("[Deprecated] Use 'hunt' instead").action(async () => {
|
|
1572
1614
|
console.warn("\u26A0\uFE0F 'protect' is deprecated \u2014 use 'bugzero hunt' instead.\n");
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -19,24 +19,29 @@ program
|
|
|
19
19
|
.description("Run build, lint, and tests — report issues without modifying files")
|
|
20
20
|
.option("-p, --path <dir>", "Path to the target project", ".")
|
|
21
21
|
.action(async (opts) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
try {
|
|
23
|
+
const cwd = path.resolve(opts.path);
|
|
24
|
+
const framework = detectFramework(cwd);
|
|
25
|
+
|
|
26
|
+
console.log(`\n🔍 BugZero — Analyzing project`);
|
|
27
|
+
console.log(` Path: ${cwd}`);
|
|
28
|
+
console.log(` Framework: ${framework}\n`);
|
|
29
|
+
|
|
30
|
+
const { build, lint, test } = await orchestrate({ cwd });
|
|
31
|
+
|
|
32
|
+
console.log("── Pipeline Summary ───────────────────────────");
|
|
33
|
+
console.log(` Build: ${build.success ? "✅ Passed" : "❌ Failed (see report)"}`);
|
|
34
|
+
console.log(` Lint: ${lint.success ? "✅ Passed" : "❌ Failed (see report)"}`);
|
|
35
|
+
console.log(` Tests: ${test.success ? "✅ Passed" : "❌ Failed (see report)"}`);
|
|
36
|
+
console.log("───────────────────────────────────────────────");
|
|
37
|
+
|
|
38
|
+
const allPassed = build.success && lint.success && test.success;
|
|
39
|
+
console.log(`\n${allPassed ? "✅ All checks passed" : "❌ Issues found — run 'bugzero rescue' to repair"}\n`);
|
|
40
|
+
process.exit(allPassed ? 0 : 1);
|
|
41
|
+
} catch (error: any) {
|
|
42
|
+
console.error(`\n❌ [BugZero] Execution failed: ${error.message || error}`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
// ── bugzero rescue ───────────────────────────────────────────────────────────
|
|
@@ -47,44 +52,49 @@ program
|
|
|
47
52
|
.option("-n, --max-attempts <number>", "Maximum AI fix attempts", "3")
|
|
48
53
|
.option("--dry-run", "Analyse only — print what would be fixed without writing files", false)
|
|
49
54
|
.action(async (opts) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
55
|
+
try {
|
|
56
|
+
const cwd = path.resolve(opts.path);
|
|
57
|
+
const maxAttempts = parseInt(opts.maxAttempts, 10);
|
|
58
|
+
const dryRun: boolean = opts.dryRun;
|
|
59
|
+
const framework = detectFramework(cwd);
|
|
60
|
+
|
|
61
|
+
console.log(`\n🤖 BugZero Fix`);
|
|
62
|
+
console.log(` Path: ${cwd}`);
|
|
63
|
+
console.log(` Framework: ${framework}`);
|
|
64
|
+
console.log(` Max attempts: ${maxAttempts}`);
|
|
65
|
+
if (dryRun) console.log(` Mode: DRY RUN (no files will be modified)`);
|
|
66
|
+
console.log();
|
|
67
|
+
|
|
68
|
+
const result = await orchestrateAndFix({ cwd, maxAttempts, dryRun });
|
|
69
|
+
|
|
70
|
+
console.log("\n──────────────────────────────────────────────");
|
|
71
|
+
if (result.success) {
|
|
72
|
+
console.log(`✅ Build fixed after ${result.attempts} attempt(s)!`);
|
|
73
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
74
|
+
if (result.promptTokens !== undefined && result.completionTokens !== undefined) {
|
|
75
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
76
|
+
}
|
|
77
|
+
if (result.appliedFix) {
|
|
78
|
+
console.log(` File: ${result.appliedFix.filePath}`);
|
|
79
|
+
console.log(` Reason: ${result.appliedFix.explanation}`);
|
|
80
|
+
console.log(` Root cause: ${result.appliedFix.rootCause}`);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
console.log(`❌ Could not fix build after ${result.attempts} attempt(s).`);
|
|
84
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
85
|
+
if (result.promptTokens !== undefined && result.completionTokens !== undefined) {
|
|
86
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
87
|
+
}
|
|
88
|
+
if (result.error) console.log(` ${result.error}`);
|
|
89
|
+
console.log(`\n👉 Full unresolved error logs have been listed in the generated report.`);
|
|
81
90
|
}
|
|
82
|
-
|
|
83
|
-
console.log(`\n👉 Full unresolved error logs have been listed in the generated report.`);
|
|
84
|
-
}
|
|
85
|
-
console.log();
|
|
91
|
+
console.log();
|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
process.exit(result.success ? 0 : 1);
|
|
94
|
+
} catch (error: any) {
|
|
95
|
+
console.error(`\n❌ [BugZero] Execution failed: ${error.message || error}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
88
98
|
});
|
|
89
99
|
|
|
90
100
|
// ── bugzero protect (legacy) ────────────────────────────────────────────────
|