bugzero 0.0.51 → 0.0.52
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/dist/index.js +72 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1741,10 +1741,76 @@ var require_dist8 = __commonJS({
|
|
|
1741
1741
|
}
|
|
1742
1742
|
var import_analyzers = require_dist2();
|
|
1743
1743
|
var import_agents = require_dist7();
|
|
1744
|
-
var
|
|
1744
|
+
var import_shared22 = require_dist4();
|
|
1745
1745
|
var import_fs3 = __toESM2(require("fs"));
|
|
1746
1746
|
var import_path3 = __toESM2(require("path"));
|
|
1747
1747
|
var import_url = require("url");
|
|
1748
|
+
var import_prompts = require_dist5();
|
|
1749
|
+
var import_shared3 = require_dist4();
|
|
1750
|
+
var MAX_REPORT_LOG_CHARS = 2e4;
|
|
1751
|
+
function capReportLogs(logs, maxChars = MAX_REPORT_LOG_CHARS) {
|
|
1752
|
+
return (0, import_prompts.truncateLogs)(logs, maxChars);
|
|
1753
|
+
}
|
|
1754
|
+
function buildHuntDiagnosisPrompt(checks) {
|
|
1755
|
+
const sections = [
|
|
1756
|
+
{ label: "BUILD FAILURE", check: checks.build },
|
|
1757
|
+
{ label: "LINT FAILURE", check: checks.lint },
|
|
1758
|
+
{ label: "TEST FAILURE", check: checks.test }
|
|
1759
|
+
].filter((section) => !section.check.success);
|
|
1760
|
+
const share = Math.floor(MAX_REPORT_LOG_CHARS / Math.max(sections.length, 1));
|
|
1761
|
+
const logs = sections.map((section) => `[${section.label}]
|
|
1762
|
+
${capReportLogs(section.check.output ?? "", share)}
|
|
1763
|
+
|
|
1764
|
+
`).join("");
|
|
1765
|
+
return `You are an expert software engineer assistant. Below is the error output from a project's build, lint, and test checks.
|
|
1766
|
+
Please analyze the errors and generate a professional, beautifully formatted Markdown report summarizing:
|
|
1767
|
+
1. **Diagnosis:** Clear explanation of what failed and why.
|
|
1768
|
+
2. **Root Cause:** The underlying issue in the code/config.
|
|
1769
|
+
3. **Action Plan:** Step-by-step instructions on what files need to be modified and what exact changes to make.
|
|
1770
|
+
|
|
1771
|
+
Failed Checks Logs:
|
|
1772
|
+
${logs}
|
|
1773
|
+
|
|
1774
|
+
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1775
|
+
}
|
|
1776
|
+
function formatPatchesForPrompt(appliedFix) {
|
|
1777
|
+
return appliedFix.patches.map(
|
|
1778
|
+
(p, i) => `File ${i + 1}: ${p.filePath}
|
|
1779
|
+
- Search code:
|
|
1780
|
+
${p.search}
|
|
1781
|
+
- Replace code:
|
|
1782
|
+
${p.replace}`
|
|
1783
|
+
).join("\n\n");
|
|
1784
|
+
}
|
|
1785
|
+
function buildRescueSuccessPrompt(params) {
|
|
1786
|
+
const { cwd, attempts, appliedFix } = params;
|
|
1787
|
+
const patchedFiles = (0, import_shared3.uniqueFilePaths)(appliedFix.patches).join(", ");
|
|
1788
|
+
return `You are an expert software engineer assistant. An automated AI agent successfully resolved a build/lint/test failure in a project located at "${cwd}" after ${attempts} attempts by applying a patch to: ${patchedFiles}.
|
|
1789
|
+
Here is the patch details:
|
|
1790
|
+
- Root Cause: ${appliedFix.rootCause}
|
|
1791
|
+
- Explanation: ${appliedFix.explanation}
|
|
1792
|
+
${formatPatchesForPrompt(appliedFix)}
|
|
1793
|
+
|
|
1794
|
+
Please generate a professional, beautifully formatted Markdown report summarizing:
|
|
1795
|
+
1. **Repair Summary:** Celebrate the success and explain the fix.
|
|
1796
|
+
2. **Details of the Solution:** Walk the developer through what was changed and why.
|
|
1797
|
+
3. **Verification:** Explain how it was verified (build, lint, tests passed).
|
|
1798
|
+
|
|
1799
|
+
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1800
|
+
}
|
|
1801
|
+
function buildRescueFailurePrompt(params) {
|
|
1802
|
+
const { cwd, attempts, rawOutput } = params;
|
|
1803
|
+
return `You are an expert software engineer assistant. An automated AI agent tried to repair build/lint/test errors in a project located at "${cwd}", but could not resolve them after ${attempts} attempts.
|
|
1804
|
+
Below is the unresolved error logs.
|
|
1805
|
+
Please analyze these logs and generate a professional, beautifully formatted Markdown report summarizing:
|
|
1806
|
+
1. **Analysis of Unresolved Errors:** Explain why the AI fixes might have failed or what is still unresolved.
|
|
1807
|
+
2. **Manual Action Plan:** Provide detailed, step-by-step instructions for the developer on how to fix this manually.
|
|
1808
|
+
|
|
1809
|
+
Unresolved Error Logs:
|
|
1810
|
+
${capReportLogs(rawOutput ?? "")}
|
|
1811
|
+
|
|
1812
|
+
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1813
|
+
}
|
|
1748
1814
|
function buildDryRunPrompt(cwd, rawOutput) {
|
|
1749
1815
|
return `You are an expert software engineer assistant. BugZero ran in dry-run mode on the project located at "${cwd}": it ran the project's build/lint/test checks and found failures, but it intentionally attempted NO fixes and modified NO files.
|
|
1750
1816
|
Below is the error output.
|
|
@@ -1754,7 +1820,7 @@ Please analyze these logs and generate a professional, beautifully formatted Mar
|
|
|
1754
1820
|
3. **Suggested Fix:** Step-by-step instructions on what files need to be modified and what exact changes to make.
|
|
1755
1821
|
|
|
1756
1822
|
Error Logs:
|
|
1757
|
-
${rawOutput}
|
|
1823
|
+
${capReportLogs(rawOutput)}
|
|
1758
1824
|
|
|
1759
1825
|
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1760
1826
|
}
|
|
@@ -1901,15 +1967,6 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
1901
1967
|
});
|
|
1902
1968
|
return result;
|
|
1903
1969
|
}
|
|
1904
|
-
function formatPatchesForPrompt(appliedFix) {
|
|
1905
|
-
return appliedFix.patches.map(
|
|
1906
|
-
(p, i) => `File ${i + 1}: ${p.filePath}
|
|
1907
|
-
- Search code:
|
|
1908
|
-
${p.search}
|
|
1909
|
-
- Replace code:
|
|
1910
|
-
${p.replace}`
|
|
1911
|
-
).join("\n\n");
|
|
1912
|
-
}
|
|
1913
1970
|
function formatPatchesMarkdown(appliedFix) {
|
|
1914
1971
|
return appliedFix.patches.map(
|
|
1915
1972
|
(p) => `**File:** \`${p.filePath}\`
|
|
@@ -1945,16 +2002,7 @@ ${test.output}
|
|
|
1945
2002
|
|
|
1946
2003
|
`;
|
|
1947
2004
|
console.log("[BugZero] Calling AI to diagnose errors and write report...");
|
|
1948
|
-
const prompt =
|
|
1949
|
-
Please analyze the errors and generate a professional, beautifully formatted Markdown report summarizing:
|
|
1950
|
-
1. **Diagnosis:** Clear explanation of what failed and why.
|
|
1951
|
-
2. **Root Cause:** The underlying issue in the code/config.
|
|
1952
|
-
3. **Action Plan:** Step-by-step instructions on what files need to be modified and what exact changes to make.
|
|
1953
|
-
|
|
1954
|
-
Failed Checks Logs:
|
|
1955
|
-
${logs}
|
|
1956
|
-
|
|
1957
|
-
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
2005
|
+
const prompt = buildHuntDiagnosisPrompt({ build, lint, test });
|
|
1958
2006
|
try {
|
|
1959
2007
|
const result = await provider.invoke(prompt, { cwd });
|
|
1960
2008
|
content = result.content;
|
|
@@ -2028,19 +2076,7 @@ Your project already passes its build, lint, and tests, so BugZero made no chang
|
|
|
2028
2076
|
}
|
|
2029
2077
|
} else if (success && appliedFix) {
|
|
2030
2078
|
console.log("[BugZero] Calling AI to write solution summary report...");
|
|
2031
|
-
const
|
|
2032
|
-
const prompt = `You are an expert software engineer assistant. An automated AI agent successfully resolved a build/lint/test failure in a project located at "${cwd}" after ${attempts} attempts by applying a patch to: ${patchedFiles}.
|
|
2033
|
-
Here is the patch details:
|
|
2034
|
-
- Root Cause: ${appliedFix.rootCause}
|
|
2035
|
-
- Explanation: ${appliedFix.explanation}
|
|
2036
|
-
${formatPatchesForPrompt(appliedFix)}
|
|
2037
|
-
|
|
2038
|
-
Please generate a professional, beautifully formatted Markdown report summarizing:
|
|
2039
|
-
1. **Repair Summary:** Celebrate the success and explain the fix.
|
|
2040
|
-
2. **Details of the Solution:** Walk the developer through what was changed and why.
|
|
2041
|
-
3. **Verification:** Explain how it was verified (build, lint, tests passed).
|
|
2042
|
-
|
|
2043
|
-
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
2079
|
+
const prompt = buildRescueSuccessPrompt({ cwd, attempts, appliedFix });
|
|
2044
2080
|
try {
|
|
2045
2081
|
const result = await provider.invoke(prompt, { cwd });
|
|
2046
2082
|
content = result.content;
|
|
@@ -2066,7 +2102,7 @@ Generate the Markdown report directly. Do not wrap it in markdown block fences (
|
|
|
2066
2102
|
- **Token Usage:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
2067
2103
|
|
|
2068
2104
|
## \u{1F6E0}\uFE0F Applied Solution
|
|
2069
|
-
- **Target File(s):** ${(0,
|
|
2105
|
+
- **Target File(s):** ${(0, import_shared22.uniqueFilePaths)(appliedFix.patches).map((file) => `\`${file}\``).join(", ")}
|
|
2070
2106
|
- **Root Cause:** ${appliedFix.rootCause}
|
|
2071
2107
|
- **Explanation:** ${appliedFix.explanation}
|
|
2072
2108
|
|
|
@@ -2076,16 +2112,7 @@ ${formatPatchesMarkdown(appliedFix)}
|
|
|
2076
2112
|
}
|
|
2077
2113
|
} else {
|
|
2078
2114
|
console.log("[BugZero] Calling AI to analyze unresolved errors and write report...");
|
|
2079
|
-
const prompt =
|
|
2080
|
-
Below is the unresolved error logs.
|
|
2081
|
-
Please analyze these logs and generate a professional, beautifully formatted Markdown report summarizing:
|
|
2082
|
-
1. **Analysis of Unresolved Errors:** Explain why the AI fixes might have failed or what is still unresolved.
|
|
2083
|
-
2. **Manual Action Plan:** Provide detailed, step-by-step instructions for the developer on how to fix this manually.
|
|
2084
|
-
|
|
2085
|
-
Unresolved Error Logs:
|
|
2086
|
-
${rawOutput}
|
|
2087
|
-
|
|
2088
|
-
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
2115
|
+
const prompt = buildRescueFailurePrompt({ cwd, attempts, rawOutput });
|
|
2089
2116
|
try {
|
|
2090
2117
|
const result = await provider.invoke(prompt, { cwd });
|
|
2091
2118
|
content = result.content;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugzero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
4
4
|
"description": "Autonomous AI-powered CLI and GitHub Action that detects build, lint, and test failures, generates multi-file patches, applies them atomically with fuzzy matching, and re-verifies until your project is green.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Saksham Agarwal (https://github.com/Saksham1800t)",
|