bugzero 0.0.25 → 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 +150 -4
- 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
|
@@ -683,9 +683,11 @@ var require_dist3 = __commonJS({
|
|
|
683
683
|
var require_dist4 = __commonJS({
|
|
684
684
|
"../prompts/dist/index.js"(exports2, module2) {
|
|
685
685
|
"use strict";
|
|
686
|
+
var __create2 = Object.create;
|
|
686
687
|
var __defProp2 = Object.defineProperty;
|
|
687
688
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
688
689
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
690
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
689
691
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
690
692
|
var __export = (target, all) => {
|
|
691
693
|
for (var name in all)
|
|
@@ -699,12 +701,155 @@ var require_dist4 = __commonJS({
|
|
|
699
701
|
}
|
|
700
702
|
return to;
|
|
701
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
|
+
));
|
|
702
712
|
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
703
713
|
var index_exports = {};
|
|
704
714
|
__export(index_exports, {
|
|
705
715
|
buildAnalysisPrompt: () => buildAnalysisPrompt
|
|
706
716
|
});
|
|
707
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
|
+
}
|
|
708
853
|
function buildAnalysisPrompt(errorOutput, cwd) {
|
|
709
854
|
const warningMarker = "\u26A0\uFE0F [BugZero System Warning]";
|
|
710
855
|
let compilerLogs = errorOutput;
|
|
@@ -721,18 +866,19 @@ ${w}`).join("\n\n")}
|
|
|
721
866
|
|
|
722
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.`;
|
|
723
868
|
}
|
|
869
|
+
const contextSection = getContextFiles(compilerLogs, cwd);
|
|
724
870
|
return `You are an expert software engineer specialising in fixing build, lint, and test failures.
|
|
725
871
|
|
|
726
872
|
A project located at "${cwd}" failed to build. Here is the complete error output:
|
|
727
873
|
|
|
728
874
|
\`\`\`
|
|
729
875
|
${compilerLogs}
|
|
730
|
-
\`\`\`${historySection}
|
|
876
|
+
\`\`\`${historySection}${contextSection}
|
|
731
877
|
|
|
732
878
|
Your task:
|
|
733
|
-
1. Identify the root cause.
|
|
734
|
-
2.
|
|
735
|
-
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.
|
|
736
882
|
|
|
737
883
|
Reply with ONLY a valid JSON object in this exact shape \u2014 no markdown fences, no extra text:
|
|
738
884
|
{
|