bugzero 0.0.51 → 0.0.53
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/README.md +7 -0
- package/dist/index.js +96 -62
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,6 +201,13 @@ Run build, lint, and test checks. Reports all failures without modifying any fil
|
|
|
201
201
|
bugzero hunt --path /path/to/your/project
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
+
When a check fails, `hunt` asks an AI model to write the diagnosis in `bugzero-report.md`, which sends your error logs to your AI provider. To keep `hunt` fully offline, add `--no-ai-report`: the report is still written, with the status of each check and the raw logs, and no network call is made.
|
|
205
|
+
```bash
|
|
206
|
+
bugzero hunt --no-ai-report
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
> **Heads-up for 1.0:** `hunt` will stop calling an AI model by default, and the AI diagnosis will become opt-in. Until then nothing changes unless you pass `--no-ai-report`.
|
|
210
|
+
|
|
204
211
|
### `bugzero rescue`
|
|
205
212
|
Run the full AI-powered repair loop. Detects build failures, generates precise code patches, applies them, and verifies the result.
|
|
206
213
|
|
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
|
}
|
|
@@ -1831,7 +1897,8 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
1831
1897
|
success: build.success && lint.success && test.success,
|
|
1832
1898
|
build,
|
|
1833
1899
|
lint,
|
|
1834
|
-
test
|
|
1900
|
+
test,
|
|
1901
|
+
aiReport: options.aiReport
|
|
1835
1902
|
});
|
|
1836
1903
|
return { build, lint, test };
|
|
1837
1904
|
}
|
|
@@ -1901,15 +1968,6 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
1901
1968
|
});
|
|
1902
1969
|
return result;
|
|
1903
1970
|
}
|
|
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
1971
|
function formatPatchesMarkdown(appliedFix) {
|
|
1914
1972
|
return appliedFix.patches.map(
|
|
1915
1973
|
(p) => `**File:** \`${p.filePath}\`
|
|
@@ -1944,28 +2002,7 @@ ${lint.output}
|
|
|
1944
2002
|
${test.output}
|
|
1945
2003
|
|
|
1946
2004
|
`;
|
|
1947
|
-
|
|
1948
|
-
const prompt = `You are an expert software engineer assistant. Below is the error output from a project's build, lint, and test checks.
|
|
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.`;
|
|
1958
|
-
try {
|
|
1959
|
-
const result = await provider.invoke(prompt, { cwd });
|
|
1960
|
-
content = result.content;
|
|
1961
|
-
content += `
|
|
1962
|
-
|
|
1963
|
-
---
|
|
1964
|
-
### \u{1F50D} BugZero Hunt Metadata
|
|
1965
|
-
- **AI Brain (Model) used for Diagnosis:** \`${result.model || "unknown"}\`
|
|
1966
|
-
- **Token Usage for Diagnosis:** ${result.usage ? `Prompt: **${result.usage.prompt_tokens}** | Completion: **${result.usage.completion_tokens}** | Total: **${result.usage.total_tokens}**` : "*N/A*"}`;
|
|
1967
|
-
} catch (e) {
|
|
1968
|
-
content = `# \u{1F50D} BugZero Hunt Report
|
|
2005
|
+
const reportWithoutAi = (modelLine, tokenLine) => `# \u{1F50D} BugZero Hunt Report
|
|
1969
2006
|
|
|
1970
2007
|
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1971
2008
|
**Project Path:** \`${cwd}\`
|
|
@@ -1981,9 +2018,27 @@ ${logs}
|
|
|
1981
2018
|
|
|
1982
2019
|
---
|
|
1983
2020
|
### \u{1F50D} BugZero Hunt Metadata
|
|
1984
|
-
- **AI Brain (Model) used for Diagnosis:**
|
|
1985
|
-
- **Token Usage for Diagnosis:**
|
|
2021
|
+
- **AI Brain (Model) used for Diagnosis:** ${modelLine}
|
|
2022
|
+
- **Token Usage for Diagnosis:** ${tokenLine}
|
|
1986
2023
|
`;
|
|
2024
|
+
if (data.aiReport === false) {
|
|
2025
|
+
console.log("[BugZero] AI report turned off (--no-ai-report) \u2014 writing the report without contacting an AI model.");
|
|
2026
|
+
content = reportWithoutAi("*None (AI report turned off)*", "*N/A*");
|
|
2027
|
+
} else {
|
|
2028
|
+
console.log("[BugZero] Calling AI to diagnose errors and write report...");
|
|
2029
|
+
const prompt = buildHuntDiagnosisPrompt({ build, lint, test });
|
|
2030
|
+
try {
|
|
2031
|
+
const result = await provider.invoke(prompt, { cwd });
|
|
2032
|
+
content = result.content;
|
|
2033
|
+
content += `
|
|
2034
|
+
|
|
2035
|
+
---
|
|
2036
|
+
### \u{1F50D} BugZero Hunt Metadata
|
|
2037
|
+
- **AI Brain (Model) used for Diagnosis:** \`${result.model || "unknown"}\`
|
|
2038
|
+
- **Token Usage for Diagnosis:** ${result.usage ? `Prompt: **${result.usage.prompt_tokens}** | Completion: **${result.usage.completion_tokens}** | Total: **${result.usage.total_tokens}**` : "*N/A*"}`;
|
|
2039
|
+
} catch (e) {
|
|
2040
|
+
content = reportWithoutAi("*None (AI call failed)*", `*N/A (AI call failed: ${e.message})*`);
|
|
2041
|
+
}
|
|
1987
2042
|
}
|
|
1988
2043
|
} else {
|
|
1989
2044
|
content = `# \u{1F50D} BugZero Hunt Report
|
|
@@ -2028,19 +2083,7 @@ Your project already passes its build, lint, and tests, so BugZero made no chang
|
|
|
2028
2083
|
}
|
|
2029
2084
|
} else if (success && appliedFix) {
|
|
2030
2085
|
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.`;
|
|
2086
|
+
const prompt = buildRescueSuccessPrompt({ cwd, attempts, appliedFix });
|
|
2044
2087
|
try {
|
|
2045
2088
|
const result = await provider.invoke(prompt, { cwd });
|
|
2046
2089
|
content = result.content;
|
|
@@ -2066,7 +2109,7 @@ Generate the Markdown report directly. Do not wrap it in markdown block fences (
|
|
|
2066
2109
|
- **Token Usage:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
2067
2110
|
|
|
2068
2111
|
## \u{1F6E0}\uFE0F Applied Solution
|
|
2069
|
-
- **Target File(s):** ${(0,
|
|
2112
|
+
- **Target File(s):** ${(0, import_shared22.uniqueFilePaths)(appliedFix.patches).map((file) => `\`${file}\``).join(", ")}
|
|
2070
2113
|
- **Root Cause:** ${appliedFix.rootCause}
|
|
2071
2114
|
- **Explanation:** ${appliedFix.explanation}
|
|
2072
2115
|
|
|
@@ -2076,16 +2119,7 @@ ${formatPatchesMarkdown(appliedFix)}
|
|
|
2076
2119
|
}
|
|
2077
2120
|
} else {
|
|
2078
2121
|
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.`;
|
|
2122
|
+
const prompt = buildRescueFailurePrompt({ cwd, attempts, rawOutput });
|
|
2089
2123
|
try {
|
|
2090
2124
|
const result = await provider.invoke(prompt, { cwd });
|
|
2091
2125
|
content = result.content;
|
|
@@ -2286,7 +2320,7 @@ function finish(exitCode, json) {
|
|
|
2286
2320
|
}
|
|
2287
2321
|
var program = new import_commander.Command();
|
|
2288
2322
|
program.name("bugzero").description("AI-powered build issue fixer \u2014 detects and repairs build errors automatically").version(version);
|
|
2289
|
-
program.command("hunt").description("Run build, lint, and tests \u2014 report issues without modifying files").option("-p, --path <dir>", "Path to the target project", ".").option("-t, --timeout <seconds>", TIMEOUT_DESCRIPTION).option("--json", JSON_DESCRIPTION).action(async (opts) => {
|
|
2323
|
+
program.command("hunt").description("Run build, lint, and tests \u2014 report issues without modifying files").option("-p, --path <dir>", "Path to the target project", ".").option("-t, --timeout <seconds>", TIMEOUT_DESCRIPTION).option("--no-ai-report", "Do not contact an AI model: write the report with the raw logs only").option("--json", JSON_DESCRIPTION).action(async (opts) => {
|
|
2290
2324
|
const json = opts.json === true;
|
|
2291
2325
|
if (json) routeLogsToStderr();
|
|
2292
2326
|
try {
|
|
@@ -2302,7 +2336,7 @@ program.command("hunt").description("Run build, lint, and tests \u2014 report is
|
|
|
2302
2336
|
console.log(` Package manager: ${packageManager}`);
|
|
2303
2337
|
if (timeoutSeconds !== void 0) console.log(` Timeout: ${timeoutSeconds}s per command`);
|
|
2304
2338
|
console.log();
|
|
2305
|
-
const { build, lint, test } = await (0, import_core.orchestrate)({ cwd, timeoutSeconds });
|
|
2339
|
+
const { build, lint, test } = await (0, import_core.orchestrate)({ cwd, timeoutSeconds, aiReport: opts.aiReport });
|
|
2306
2340
|
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");
|
|
2307
2341
|
const label = (r) => r.skipped ? "\u23ED\uFE0F Skipped (no script)" : r.success ? "\u2705 Passed" : "\u274C Failed (see report)";
|
|
2308
2342
|
console.log(` Build: ${label(build)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugzero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
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)",
|