bugzero 0.0.40 → 0.0.41

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 CHANGED
@@ -100,7 +100,7 @@ bugzero rescue
100
100
  ### Safety
101
101
 
102
102
  - **Backups on every patch.** Each file BugZero modifies gets a `.opspilot.bak` copy of its original content first.
103
- - **Dry-run mode.** `bugzero rescue --dry-run` runs validation and error analysis, but makes no fix attempts and never modifies your source files (a report is still written). It exits with code 1 if it found failures and 0 if everything already passes, so you can use it as a check in scripts.
103
+ - **Dry-run mode.** `bugzero rescue --dry-run` runs validation and error analysis, but makes no fix attempts and never modifies your source files (it still writes a report that diagnoses the failures it found). It exits with code 1 if it found failures and 0 if everything already passes, so you can use it as a check in scripts.
104
104
  - **Prompt size limits.** Very long error output and very large source files are shortened before being sent to the model (for logs, the start and end are kept), so a big failure can't exceed the model's context window or waste tokens.
105
105
 
106
106
  ### Project awareness
package/dist/index.js CHANGED
@@ -1491,6 +1491,51 @@ var require_dist7 = __commonJS({
1491
1491
  var import_fs3 = __toESM2(require("fs"));
1492
1492
  var import_path3 = __toESM2(require("path"));
1493
1493
  var import_url = require("url");
1494
+ function buildDryRunPrompt(cwd, rawOutput) {
1495
+ 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.
1496
+ Below is the error output.
1497
+ Please analyze these logs and generate a professional, beautifully formatted Markdown report summarizing:
1498
+ 1. **Diagnosis:** Clear explanation of what failed and why.
1499
+ 2. **Root Cause:** The underlying issue in the code or config.
1500
+ 3. **Suggested Fix:** Step-by-step instructions on what files need to be modified and what exact changes to make.
1501
+
1502
+ Error Logs:
1503
+ ${rawOutput}
1504
+
1505
+ Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
1506
+ }
1507
+ function buildDryRunMetadata(response) {
1508
+ const usage = response.usage ? `Prompt: **${response.usage.prompt_tokens}** | Completion: **${response.usage.completion_tokens}** | Total: **${response.usage.total_tokens}**` : "*N/A*";
1509
+ return `
1510
+
1511
+ ---
1512
+ ### \u{1F50D} BugZero Dry Run Metadata
1513
+ - **Mode:** Dry run (no fixes attempted, no files modified)
1514
+ - **AI Brain (Model) used for Diagnosis:** \`${response.model || "unknown"}\`
1515
+ - **Token Usage for Diagnosis:** ${usage}`;
1516
+ }
1517
+ function buildDryRunFallbackReport(params) {
1518
+ const aiNote = params.aiError ? `
1519
+ *AI diagnosis was unavailable for this report: ${params.aiError}*
1520
+ ` : "";
1521
+ return `# \u{1F50D} BugZero Dry Run Report
1522
+
1523
+ **Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
1524
+ **Project Path:** \`${params.cwd}\`
1525
+ **Framework:** \`${params.framework}\`
1526
+
1527
+ ## \u{1F4CA} Summary
1528
+ - **Mode:** Dry run \u2014 no fixes were attempted and no files were modified
1529
+ - **Result:** \u274C Failures detected
1530
+ ${aiNote}
1531
+ ## \u274C Detected Errors & Logs
1532
+ \`\`\`text
1533
+ ${params.rawOutput}
1534
+ \`\`\`
1535
+
1536
+ Re-run without \`--dry-run\` to let BugZero attempt a fix.
1537
+ `;
1538
+ }
1494
1539
  var DEFAULT_MAX_ATTEMPTS = 3;
1495
1540
  function resolveMaxAttempts2(value) {
1496
1541
  const attempts = value ?? DEFAULT_MAX_ATTEMPTS;
@@ -1552,7 +1597,8 @@ var require_dist7 = __commonJS({
1552
1597
  attempts: 0,
1553
1598
  maxAttempts,
1554
1599
  error: "Dry-run: analysis complete, no files modified.",
1555
- rawOutput: pipelineResult.output
1600
+ rawOutput: pipelineResult.output,
1601
+ dryRun: true
1556
1602
  });
1557
1603
  return {
1558
1604
  success: false,
@@ -1689,7 +1735,20 @@ ${logs}
1689
1735
  }
1690
1736
  } else {
1691
1737
  const { success, attempts, maxAttempts, appliedFix, error, rawOutput, modelUsed, promptTokens, completionTokens } = data;
1692
- if (success && appliedFix) {
1738
+ if (data.dryRun) {
1739
+ console.log("[BugZero] Calling AI to diagnose the detected errors and write report...");
1740
+ try {
1741
+ const result = await provider.invoke(buildDryRunPrompt(cwd, rawOutput ?? ""), { cwd });
1742
+ content = result.content + buildDryRunMetadata(result);
1743
+ } catch (e) {
1744
+ content = buildDryRunFallbackReport({
1745
+ cwd,
1746
+ framework: detectFramework2(cwd),
1747
+ rawOutput: rawOutput ?? "",
1748
+ aiError: e.message
1749
+ });
1750
+ }
1751
+ } else if (success && appliedFix) {
1693
1752
  console.log("[BugZero] Calling AI to write solution summary report...");
1694
1753
  const patchedFiles = appliedFix.patches.map((p) => p.filePath).join(", ");
1695
1754
  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}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bugzero",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
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)",