bugzero 0.0.24 → 0.0.26
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 +162 -6
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> bugzero@0.0.
|
|
2
|
+
> bugzero@0.0.26 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[32m68.76 KB[39m
|
|
11
|
+
[32mCJS[39m ⚡️ Build success in 1065ms
|
|
12
12
|
[34mDTS[39m Build start
|
|
13
|
-
[32mDTS[39m ⚡️ Build success in
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 4371ms
|
|
14
14
|
[32mDTS[39m [1mdist\index.d.ts [22m[32m20.00 B[39m
|
package/dist/index.js
CHANGED
|
@@ -659,8 +659,18 @@ var require_dist3 = __commonJS({
|
|
|
659
659
|
\u274C [BugZero] OpenRouter API Error: ${msg}`);
|
|
660
660
|
if (error.response?.status === 401) {
|
|
661
661
|
console.error(`\u{1F449} Please check if your OPENROUTER_API_KEY is correct and active.`);
|
|
662
|
-
} else if (error.response?.status === 429) {
|
|
663
|
-
console.error(
|
|
662
|
+
} else if (error.response?.status === 429 || error.response?.status === 402 || /credit/i.test(msg) || /token/i.test(msg)) {
|
|
663
|
+
console.error(`
|
|
664
|
+
\u{1F449} You have insufficient OpenRouter credits (or too low balance) for the selected model.`);
|
|
665
|
+
console.error(`\u{1F449} We suggest using the 'bugzero vibe' command to change to a FREE model:`);
|
|
666
|
+
console.error(` 1. Run the command: npx bugzero@latest vibe (or bugzero vibe)`);
|
|
667
|
+
console.error(` 2. Select "Custom Model" and enter one of these free model IDs:`);
|
|
668
|
+
console.error(` - google/gemma-2-9b-it:free`);
|
|
669
|
+
console.error(` - meta-llama/llama-3-8b-instruct:free`);
|
|
670
|
+
console.error(` - mistralai/mistral-7b-instruct:free`);
|
|
671
|
+
console.error(` - microsoft/phi-3-medium-128k-instruct:free`);
|
|
672
|
+
console.error(` - nvidia/llama-3.1-nemotron-70b-instruct:free
|
|
673
|
+
`);
|
|
664
674
|
}
|
|
665
675
|
throw new Error(`OpenRouter API failed: ${msg}`);
|
|
666
676
|
}
|
|
@@ -673,9 +683,11 @@ var require_dist3 = __commonJS({
|
|
|
673
683
|
var require_dist4 = __commonJS({
|
|
674
684
|
"../prompts/dist/index.js"(exports2, module2) {
|
|
675
685
|
"use strict";
|
|
686
|
+
var __create2 = Object.create;
|
|
676
687
|
var __defProp2 = Object.defineProperty;
|
|
677
688
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
678
689
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
690
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
679
691
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
680
692
|
var __export = (target, all) => {
|
|
681
693
|
for (var name in all)
|
|
@@ -689,12 +701,155 @@ var require_dist4 = __commonJS({
|
|
|
689
701
|
}
|
|
690
702
|
return to;
|
|
691
703
|
};
|
|
704
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
705
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
706
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
707
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
708
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
709
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
710
|
+
mod
|
|
711
|
+
));
|
|
692
712
|
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
693
713
|
var index_exports = {};
|
|
694
714
|
__export(index_exports, {
|
|
695
715
|
buildAnalysisPrompt: () => buildAnalysisPrompt
|
|
696
716
|
});
|
|
697
717
|
module2.exports = __toCommonJS(index_exports);
|
|
718
|
+
var import_fs = __toESM2(require("fs"));
|
|
719
|
+
var import_path2 = __toESM2(require("path"));
|
|
720
|
+
function resolveExistingPathPrefix(candidate) {
|
|
721
|
+
let current = candidate.replace(/(?::\d+)+$/, "").replace(/['"()\[\]`]+$/, "").trim();
|
|
722
|
+
while (current.length > 0) {
|
|
723
|
+
try {
|
|
724
|
+
if (import_fs.default.existsSync(current)) {
|
|
725
|
+
return current;
|
|
726
|
+
}
|
|
727
|
+
} catch {
|
|
728
|
+
}
|
|
729
|
+
const lastSpace = current.lastIndexOf(" ");
|
|
730
|
+
if (lastSpace === -1) {
|
|
731
|
+
const lastSlash = Math.max(current.lastIndexOf("/"), current.lastIndexOf("\\"));
|
|
732
|
+
if (lastSlash === -1) {
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
current = current.slice(0, lastSlash).trim();
|
|
736
|
+
} else {
|
|
737
|
+
current = current.slice(0, lastSpace).trim();
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
function getContextFiles(logs, cwd) {
|
|
743
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
744
|
+
const quotedRegex = /['"`]([^'"`\n]+)['"`]/g;
|
|
745
|
+
let match;
|
|
746
|
+
while ((match = quotedRegex.exec(logs)) !== null) {
|
|
747
|
+
const p = match[1].trim();
|
|
748
|
+
if (p.includes("/") || p.includes("\\") || p === "." || p.startsWith(".")) {
|
|
749
|
+
candidates.add(p);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
const winAbsRegex = /([a-zA-Z]:\\[^*?"<>|\n\r]+)/g;
|
|
753
|
+
while ((match = winAbsRegex.exec(logs)) !== null) {
|
|
754
|
+
candidates.add(match[1].trim());
|
|
755
|
+
}
|
|
756
|
+
const unixAbsRegex = /(\/[^*?"<>|\n\r\t]+)/g;
|
|
757
|
+
while ((match = unixAbsRegex.exec(logs)) !== null) {
|
|
758
|
+
candidates.add(match[1].trim());
|
|
759
|
+
}
|
|
760
|
+
const fallbackRegex = /(?:[a-zA-Z]:)?[a-zA-Z0-9_\-\/\\.]+\.(?:tsx?|jsx?|json|css|html|js|jsx)/g;
|
|
761
|
+
const fallbackMatches = logs.match(fallbackRegex) || [];
|
|
762
|
+
for (const m of fallbackMatches) {
|
|
763
|
+
candidates.add(m.trim());
|
|
764
|
+
}
|
|
765
|
+
const resolvedPaths = /* @__PURE__ */ new Set();
|
|
766
|
+
for (const candidate of candidates) {
|
|
767
|
+
const absPathCandidate = import_path2.default.isAbsolute(candidate) ? candidate : import_path2.default.resolve(cwd, candidate);
|
|
768
|
+
const resolved = resolveExistingPathPrefix(absPathCandidate);
|
|
769
|
+
if (resolved) {
|
|
770
|
+
resolvedPaths.add(import_path2.default.resolve(resolved));
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
if (resolvedPaths.size === 0) return "";
|
|
774
|
+
let context = "\n\n### \u{1F4C1} Codebase Context:\n";
|
|
775
|
+
const processedFiles = /* @__PURE__ */ new Set();
|
|
776
|
+
const addFileToContext = (filePath) => {
|
|
777
|
+
const relPath = import_path2.default.relative(cwd, filePath);
|
|
778
|
+
if (relPath.includes("node_modules") || relPath.startsWith("build") || relPath.startsWith("dist") || relPath.startsWith(".git")) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
if (processedFiles.has(filePath)) return;
|
|
782
|
+
processedFiles.add(filePath);
|
|
783
|
+
try {
|
|
784
|
+
const content = import_fs.default.readFileSync(filePath, "utf-8");
|
|
785
|
+
context += `
|
|
786
|
+
--- File: ${relPath} ---
|
|
787
|
+
\`\`\`
|
|
788
|
+
${content}
|
|
789
|
+
\`\`\`
|
|
790
|
+
`;
|
|
791
|
+
} catch {
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
for (const absPath of resolvedPaths) {
|
|
795
|
+
try {
|
|
796
|
+
const stats = import_fs.default.statSync(absPath);
|
|
797
|
+
if (stats.isFile()) {
|
|
798
|
+
addFileToContext(absPath);
|
|
799
|
+
const parentDir = import_path2.default.dirname(absPath);
|
|
800
|
+
const filesInDir = import_fs.default.readdirSync(parentDir);
|
|
801
|
+
const relParentDir = import_path2.default.relative(cwd, parentDir) || ".";
|
|
802
|
+
context += `
|
|
803
|
+
--- Directory files in "${relParentDir}": ---
|
|
804
|
+
`;
|
|
805
|
+
for (const file of filesInDir) {
|
|
806
|
+
try {
|
|
807
|
+
const fileStats = import_fs.default.statSync(import_path2.default.join(parentDir, file));
|
|
808
|
+
const marker = fileStats.isDirectory() ? "/" : "";
|
|
809
|
+
context += `- ${file}${marker}
|
|
810
|
+
`;
|
|
811
|
+
} catch {
|
|
812
|
+
context += `- ${file}
|
|
813
|
+
`;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
} else if (stats.isDirectory()) {
|
|
817
|
+
const relParentDir = import_path2.default.relative(cwd, absPath) || ".";
|
|
818
|
+
if (relParentDir !== ".") {
|
|
819
|
+
const filesInDir = import_fs.default.readdirSync(absPath);
|
|
820
|
+
context += `
|
|
821
|
+
--- Directory files in "${relParentDir}": ---
|
|
822
|
+
`;
|
|
823
|
+
for (const file of filesInDir) {
|
|
824
|
+
try {
|
|
825
|
+
const fileStats = import_fs.default.statSync(import_path2.default.join(absPath, file));
|
|
826
|
+
const marker = fileStats.isDirectory() ? "/" : "";
|
|
827
|
+
context += `- ${file}${marker}
|
|
828
|
+
`;
|
|
829
|
+
} catch {
|
|
830
|
+
context += `- ${file}
|
|
831
|
+
`;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (filesInDir.length <= 15) {
|
|
835
|
+
for (const file of filesInDir) {
|
|
836
|
+
const filePathFull = import_path2.default.join(absPath, file);
|
|
837
|
+
const fileExt = import_path2.default.extname(file).toLowerCase();
|
|
838
|
+
try {
|
|
839
|
+
if (import_fs.default.statSync(filePathFull).isFile() && [".js", ".jsx", ".ts", ".tsx", ".json", ".css"].includes(fileExt)) {
|
|
840
|
+
addFileToContext(filePathFull);
|
|
841
|
+
}
|
|
842
|
+
} catch {
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
} catch {
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return context;
|
|
852
|
+
}
|
|
698
853
|
function buildAnalysisPrompt(errorOutput, cwd) {
|
|
699
854
|
const warningMarker = "\u26A0\uFE0F [BugZero System Warning]";
|
|
700
855
|
let compilerLogs = errorOutput;
|
|
@@ -711,18 +866,19 @@ ${w}`).join("\n\n")}
|
|
|
711
866
|
|
|
712
867
|
**CRITICAL RULE:** Do NOT suggest modifying or creating the files listed under "Previous Failed Attempts" if they failed with a "File not found" or "Search string not found" error. You must inspect the compiler error logs below to find the actual file that exists and contains the error.`;
|
|
713
868
|
}
|
|
869
|
+
const contextSection = getContextFiles(compilerLogs, cwd);
|
|
714
870
|
return `You are an expert software engineer specialising in fixing build, lint, and test failures.
|
|
715
871
|
|
|
716
872
|
A project located at "${cwd}" failed to build. Here is the complete error output:
|
|
717
873
|
|
|
718
874
|
\`\`\`
|
|
719
875
|
${compilerLogs}
|
|
720
|
-
\`\`\`${historySection}
|
|
876
|
+
\`\`\`${historySection}${contextSection}
|
|
721
877
|
|
|
722
878
|
Your task:
|
|
723
|
-
1. Identify the root cause.
|
|
724
|
-
2.
|
|
725
|
-
3. Provide the minimal, precise fix.
|
|
879
|
+
1. Root Cause: Identify the root cause of the build failure.
|
|
880
|
+
2. Codebase Context: Read the provided file contents and directory listings under "\u{1F4C1} Codebase Context" to locate the correct files, imports, and file paths. Do not guess filenames or contents that are not in the context.
|
|
881
|
+
3. Patch: Provide the minimal, precise fix.
|
|
726
882
|
|
|
727
883
|
Reply with ONLY a valid JSON object in this exact shape \u2014 no markdown fences, no extra text:
|
|
728
884
|
{
|