bugzero 0.0.56 → 0.0.57
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 +9 -0
- package/dist/index.js +203 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -218,6 +218,14 @@ When it fixes your project, `rescue` prints a diff of exactly what changed in ea
|
|
|
218
218
|
bugzero rescue --path /path/to/your/project
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
+
**Review each fix first with `--approve`.** BugZero shows the AI's proposed change as a diff and asks before it writes anything:
|
|
222
|
+
|
|
223
|
+
```text
|
|
224
|
+
Apply this change? [y] yes [n] no [m] no, and leave a note for the AI (Enter = no):
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The whole proposed fix is shown at once, because a fix that spans several files is applied together or not at all. Answer `y` to apply it. Answer `n` (or just press Enter) to decline: nothing is changed, and the AI is told you declined and asked for a different fix, which uses up one attempt. Answer `m` to decline and type a short note that is sent to the AI, such as "leave the config file alone". `--approve` needs an interactive terminal; without one (in CI, or with piped input) it stops immediately, before running anything. It has no effect with `--dry-run` or `--print-prompt`, which never write.
|
|
228
|
+
|
|
221
229
|
<details>
|
|
222
230
|
<summary><strong>Options for <code>rescue</code></strong></summary>
|
|
223
231
|
|
|
@@ -227,6 +235,7 @@ bugzero rescue --path /path/to/your/project
|
|
|
227
235
|
| `--max-attempts <n>` | `-n` | `3` | Maximum AI fix iterations before giving up |
|
|
228
236
|
| `--timeout <seconds>` | `-t` | none | Stop any build, lint, or test command that runs longer than this many seconds |
|
|
229
237
|
| `--dry-run` | | `false` | Analyze only — no files will be written |
|
|
238
|
+
| `--approve` | | `false` | Show each proposed fix as a diff and ask before writing it. Needs an interactive terminal |
|
|
230
239
|
| `--print-prompt` | | `false` | Print the exact prompt that would be sent to the AI model, then stop. Nothing is sent and no files are written |
|
|
231
240
|
| `--json` | | `false` | Print the result as one JSON document on stdout (logs go to stderr) |
|
|
232
241
|
|
package/dist/index.js
CHANGED
|
@@ -1331,8 +1331,11 @@ var require_dist6 = __commonJS({
|
|
|
1331
1331
|
applyPatches: () => applyPatches,
|
|
1332
1332
|
findMatch: () => findMatch,
|
|
1333
1333
|
lineSimilarity: () => lineSimilarity,
|
|
1334
|
+
patchContent: () => patchContent,
|
|
1335
|
+
previewPatches: () => previewPatches,
|
|
1334
1336
|
renderChangesFromBackups: () => renderChangesFromBackups2,
|
|
1335
|
-
renderUnifiedDiff: () => renderUnifiedDiff
|
|
1337
|
+
renderUnifiedDiff: () => renderUnifiedDiff,
|
|
1338
|
+
resolvePatchTargets: () => resolvePatchTargets
|
|
1336
1339
|
});
|
|
1337
1340
|
module2.exports = __toCommonJS(index_exports);
|
|
1338
1341
|
var import_fs2 = __toESM2(require("fs"));
|
|
@@ -1456,6 +1459,18 @@ var require_dist6 = __commonJS({
|
|
|
1456
1459
|
function withLineEnding(text, ending) {
|
|
1457
1460
|
return text.replace(/\r\n|\n/g, ending);
|
|
1458
1461
|
}
|
|
1462
|
+
function patchContent(original, search, replace, fileName) {
|
|
1463
|
+
const match = findMatch(original, search);
|
|
1464
|
+
if (!match) {
|
|
1465
|
+
return {
|
|
1466
|
+
ok: false,
|
|
1467
|
+
error: `Search string not found in ${fileName} (tried exact, whitespace-normalized, and fuzzy matching). The AI's "search" field did not match file content.`
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
const replacement = withLineEnding(replace, detectLineEnding(original, match.start, match.end));
|
|
1471
|
+
const content = original.slice(0, match.start) + replacement + original.slice(match.end);
|
|
1472
|
+
return { ok: true, content, matchStrategy: match.strategy };
|
|
1473
|
+
}
|
|
1459
1474
|
function applyPatch(absoluteFilePath, search, replace, options = {}) {
|
|
1460
1475
|
try {
|
|
1461
1476
|
if (!import_fs2.default.existsSync(absoluteFilePath)) {
|
|
@@ -1465,27 +1480,40 @@ var require_dist6 = __commonJS({
|
|
|
1465
1480
|
};
|
|
1466
1481
|
}
|
|
1467
1482
|
const original = import_fs2.default.readFileSync(absoluteFilePath, "utf-8");
|
|
1468
|
-
const
|
|
1469
|
-
if (!
|
|
1470
|
-
return {
|
|
1471
|
-
success: false,
|
|
1472
|
-
error: `Search string not found in ${import_path2.default.basename(absoluteFilePath)} (tried exact, whitespace-normalized, and fuzzy matching). The AI's "search" field did not match file content.`
|
|
1473
|
-
};
|
|
1474
|
-
}
|
|
1483
|
+
const patched = patchContent(original, search, replace, import_path2.default.basename(absoluteFilePath));
|
|
1484
|
+
if (!patched.ok) return { success: false, error: patched.error };
|
|
1475
1485
|
const backupPath = absoluteFilePath + ".opspilot.bak";
|
|
1476
1486
|
if (options.backup !== false) {
|
|
1477
1487
|
import_fs2.default.writeFileSync(backupPath, original, "utf-8");
|
|
1478
1488
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
import_fs2.default.writeFileSync(absoluteFilePath, fixed, "utf-8");
|
|
1482
|
-
return { success: true, backupPath, matchStrategy: match.strategy };
|
|
1489
|
+
import_fs2.default.writeFileSync(absoluteFilePath, patched.content, "utf-8");
|
|
1490
|
+
return { success: true, backupPath, matchStrategy: patched.matchStrategy };
|
|
1483
1491
|
} catch (err) {
|
|
1484
1492
|
return { success: false, error: err.message };
|
|
1485
1493
|
}
|
|
1486
1494
|
}
|
|
1487
|
-
var import_shared3 = require_dist4();
|
|
1488
1495
|
var import_fs22 = __toESM2(require("fs"));
|
|
1496
|
+
var import_shared3 = require_dist4();
|
|
1497
|
+
function resolvePatchTargets(cwd, patches, protection = (0, import_shared3.createProtectedPathRules)()) {
|
|
1498
|
+
const absolutePaths = [];
|
|
1499
|
+
for (const patch of patches) {
|
|
1500
|
+
const resolved = (0, import_shared3.resolveInsideProject)(cwd, patch.filePath);
|
|
1501
|
+
if (!resolved.ok) {
|
|
1502
|
+
return { ok: false, error: `Failed to patch "${patch.filePath}": ${resolved.error}` };
|
|
1503
|
+
}
|
|
1504
|
+
for (const relPath of (0, import_shared3.projectRelativePaths)(cwd, resolved.absolutePath)) {
|
|
1505
|
+
const pattern = protection.editBlockedBy(relPath);
|
|
1506
|
+
if (pattern !== void 0) {
|
|
1507
|
+
return {
|
|
1508
|
+
ok: false,
|
|
1509
|
+
error: `Failed to patch "${patch.filePath}": this file is protected (it matches "${pattern}"), so BugZero never edits it. Fix the problem in a different file.`
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
absolutePaths.push(resolved.absolutePath);
|
|
1514
|
+
}
|
|
1515
|
+
return { ok: true, absolutePaths };
|
|
1516
|
+
}
|
|
1489
1517
|
function rollback(originalContent, backupPaths) {
|
|
1490
1518
|
for (const [absolutePath, content] of originalContent) {
|
|
1491
1519
|
try {
|
|
@@ -1504,29 +1532,11 @@ var require_dist6 = __commonJS({
|
|
|
1504
1532
|
if (patches.length === 0) {
|
|
1505
1533
|
return { success: false, error: "No patches to apply.", applied: [] };
|
|
1506
1534
|
}
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
const resolved = (0, import_shared3.resolveInsideProject)(cwd, patch.filePath);
|
|
1511
|
-
if (!resolved.ok) {
|
|
1512
|
-
return {
|
|
1513
|
-
success: false,
|
|
1514
|
-
error: `Failed to patch "${patch.filePath}": ${resolved.error}`,
|
|
1515
|
-
applied: []
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
for (const relPath of (0, import_shared3.projectRelativePaths)(cwd, resolved.absolutePath)) {
|
|
1519
|
-
const pattern = protection.editBlockedBy(relPath);
|
|
1520
|
-
if (pattern !== void 0) {
|
|
1521
|
-
return {
|
|
1522
|
-
success: false,
|
|
1523
|
-
error: `Failed to patch "${patch.filePath}": this file is protected (it matches "${pattern}"), so BugZero never edits it. Fix the problem in a different file.`,
|
|
1524
|
-
applied: []
|
|
1525
|
-
};
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
absolutePaths.push(resolved.absolutePath);
|
|
1535
|
+
const targets = resolvePatchTargets(cwd, patches, options.protection);
|
|
1536
|
+
if (!targets.ok) {
|
|
1537
|
+
return { success: false, error: targets.error, applied: [] };
|
|
1529
1538
|
}
|
|
1539
|
+
const absolutePaths = targets.absolutePaths;
|
|
1530
1540
|
const originalContent = /* @__PURE__ */ new Map();
|
|
1531
1541
|
const backupPaths = /* @__PURE__ */ new Set();
|
|
1532
1542
|
const applied = [];
|
|
@@ -1731,6 +1741,41 @@ var require_dist6 = __commonJS({
|
|
|
1731
1741
|
}
|
|
1732
1742
|
return renderUnifiedDiff(changes, options);
|
|
1733
1743
|
}
|
|
1744
|
+
var import_fs4 = __toESM2(require("fs"));
|
|
1745
|
+
var import_path3 = __toESM2(require("path"));
|
|
1746
|
+
function previewPatches(cwd, patches, options = {}) {
|
|
1747
|
+
if (patches.length === 0) {
|
|
1748
|
+
return { success: false, error: "No patches to apply." };
|
|
1749
|
+
}
|
|
1750
|
+
const targets = resolvePatchTargets(cwd, patches, options.protection);
|
|
1751
|
+
if (!targets.ok) return { success: false, error: targets.error };
|
|
1752
|
+
const originals = /* @__PURE__ */ new Map();
|
|
1753
|
+
const current = /* @__PURE__ */ new Map();
|
|
1754
|
+
for (const [index, patch] of patches.entries()) {
|
|
1755
|
+
const absolutePath = targets.absolutePaths[index];
|
|
1756
|
+
if (!current.has(absolutePath)) {
|
|
1757
|
+
try {
|
|
1758
|
+
const content = import_fs4.default.readFileSync(absolutePath, "utf-8");
|
|
1759
|
+
originals.set(absolutePath, content);
|
|
1760
|
+
current.set(absolutePath, content);
|
|
1761
|
+
} catch {
|
|
1762
|
+
return { success: false, error: `Failed to patch "${patch.filePath}": File not found: ${absolutePath}` };
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
const patched = patchContent(current.get(absolutePath), patch.search, patch.replace, import_path3.default.basename(absolutePath));
|
|
1766
|
+
if (!patched.ok) {
|
|
1767
|
+
return { success: false, error: `Failed to patch "${patch.filePath}": ${patched.error}` };
|
|
1768
|
+
}
|
|
1769
|
+
current.set(absolutePath, patched.content);
|
|
1770
|
+
}
|
|
1771
|
+
const root = import_path3.default.resolve(cwd);
|
|
1772
|
+
const changes = [...originals.keys()].map((absolutePath) => ({
|
|
1773
|
+
filePath: import_path3.default.relative(root, absolutePath).split(import_path3.default.sep).join("/"),
|
|
1774
|
+
before: originals.get(absolutePath),
|
|
1775
|
+
after: current.get(absolutePath)
|
|
1776
|
+
}));
|
|
1777
|
+
return { success: true, changes };
|
|
1778
|
+
}
|
|
1734
1779
|
}
|
|
1735
1780
|
});
|
|
1736
1781
|
|
|
@@ -1847,6 +1892,16 @@ var require_dist7 = __commonJS({
|
|
|
1847
1892
|
reducer: (old, value) => old + value,
|
|
1848
1893
|
default: () => 0
|
|
1849
1894
|
}),
|
|
1895
|
+
/** When set, each proposed fix is shown to this handler and only written if it approves */
|
|
1896
|
+
approve: (0, import_langgraph.Annotation)({
|
|
1897
|
+
reducer: (_, value) => value,
|
|
1898
|
+
default: () => void 0
|
|
1899
|
+
}),
|
|
1900
|
+
/** How many proposed fixes the person declined */
|
|
1901
|
+
declinedFixes: (0, import_langgraph.Annotation)({
|
|
1902
|
+
reducer: (total, added) => total + added,
|
|
1903
|
+
default: () => 0
|
|
1904
|
+
}),
|
|
1850
1905
|
/** Per-command timeout in milliseconds for validation steps (undefined = no limit) */
|
|
1851
1906
|
timeoutMs: (0, import_langgraph.Annotation)({
|
|
1852
1907
|
reducer: (_, value) => value,
|
|
@@ -1900,6 +1955,19 @@ var require_dist7 = __commonJS({
|
|
|
1900
1955
|
completionTokens: result.usage?.completion_tokens ?? 0
|
|
1901
1956
|
};
|
|
1902
1957
|
}
|
|
1958
|
+
function patchFailure(state, error) {
|
|
1959
|
+
console.error(`[BugZero] Patch failed: ${error}`);
|
|
1960
|
+
const updatedLogs = `${state.logs}
|
|
1961
|
+
|
|
1962
|
+
\u26A0\uFE0F [BugZero System Warning] Your previous patch suggestion failed with the following error:
|
|
1963
|
+
- ${error}
|
|
1964
|
+
|
|
1965
|
+
Any other files from that same suggestion were rolled back to keep the change atomic. Please check if the file path(s) are correct relative to the project root and make sure you target the correct file(s) that contain the build error.`;
|
|
1966
|
+
return {
|
|
1967
|
+
logs: updatedLogs,
|
|
1968
|
+
patchFailed: true
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1903
1971
|
async function applyFixNode(state) {
|
|
1904
1972
|
if (!state.fixSuggestion) {
|
|
1905
1973
|
console.warn("[BugZero] No fix suggestion available \u2014 skipping patch.");
|
|
@@ -1909,23 +1977,33 @@ var require_dist7 = __commonJS({
|
|
|
1909
1977
|
const fileList = patches.map((p) => p.filePath).join(", ");
|
|
1910
1978
|
console.log(`[BugZero] Patching ${patches.length} file${patches.length === 1 ? "" : "s"}: ${fileList}`);
|
|
1911
1979
|
console.log(`[BugZero] Reason: ${explanation}`);
|
|
1980
|
+
if (state.approve) {
|
|
1981
|
+
const preview = (0, import_patcher2.previewPatches)(state.cwd, patches, { protection: protectionFor(state.cwd) });
|
|
1982
|
+
if (!preview.success) return patchFailure(state, preview.error);
|
|
1983
|
+
const files = preview.changes.map((change) => change.filePath);
|
|
1984
|
+
const decision = await state.approve({
|
|
1985
|
+
attempt: state.attempts,
|
|
1986
|
+
maxAttempts: state.maxAttempts,
|
|
1987
|
+
rootCause: state.fixSuggestion.rootCause,
|
|
1988
|
+
explanation,
|
|
1989
|
+
files,
|
|
1990
|
+
diff: (0, import_patcher2.renderUnifiedDiff)(preview.changes)
|
|
1991
|
+
});
|
|
1992
|
+
if (!decision.approved) {
|
|
1993
|
+
console.log("[BugZero] Fix declined \u2014 nothing was changed.");
|
|
1994
|
+
const note = decision.note?.trim();
|
|
1995
|
+
const userNote = note ? ` The user's note: "${note}".` : "";
|
|
1996
|
+
const declinedLogs = `${state.logs}
|
|
1997
|
+
|
|
1998
|
+
\u26A0\uFE0F [BugZero System Warning] Your previous patch suggestion was declined by the user, so nothing was changed. The files it would have changed were: ${files.join(", ")}.${userNote} Propose a different fix.`;
|
|
1999
|
+
return { logs: declinedLogs, patchFailed: true, declinedFixes: 1 };
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
1912
2002
|
const result = (0, import_patcher2.applyPatches)(state.cwd, patches, {
|
|
1913
2003
|
alreadyBackedUp: state.backedUpFiles,
|
|
1914
2004
|
protection: protectionFor(state.cwd)
|
|
1915
2005
|
});
|
|
1916
|
-
if (!result.success)
|
|
1917
|
-
console.error(`[BugZero] Patch failed: ${result.error}`);
|
|
1918
|
-
const updatedLogs = `${state.logs}
|
|
1919
|
-
|
|
1920
|
-
\u26A0\uFE0F [BugZero System Warning] Your previous patch suggestion failed with the following error:
|
|
1921
|
-
- ${result.error}
|
|
1922
|
-
|
|
1923
|
-
Any other files from that same suggestion were rolled back to keep the change atomic. Please check if the file path(s) are correct relative to the project root and make sure you target the correct file(s) that contain the build error.`;
|
|
1924
|
-
return {
|
|
1925
|
-
logs: updatedLogs,
|
|
1926
|
-
patchFailed: true
|
|
1927
|
-
};
|
|
1928
|
-
}
|
|
2006
|
+
if (!result.success) return patchFailure(state, result.error);
|
|
1929
2007
|
for (const applied of result.applied) {
|
|
1930
2008
|
console.log(`[BugZero] Backup saved to: ${applied.backupPath}`);
|
|
1931
2009
|
if (applied.matchStrategy !== "exact") {
|
|
@@ -2189,6 +2267,14 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
2189
2267
|
}
|
|
2190
2268
|
var import_ai_provider = require_dist3();
|
|
2191
2269
|
var REPORT_FILENAME2 = "bugzero-report.md";
|
|
2270
|
+
function failureMessage(maxAttempts, declined, appliedAnything) {
|
|
2271
|
+
const plural = declined === 1 ? "fix" : "fixes";
|
|
2272
|
+
if (declined > 0 && !appliedAnything) {
|
|
2273
|
+
return `You declined ${declined} proposed ${plural}, so nothing was changed.`;
|
|
2274
|
+
}
|
|
2275
|
+
const base = `Max attempts (${maxAttempts}) reached without a successful build.`;
|
|
2276
|
+
return declined > 0 ? `${base} You declined ${declined} proposed ${plural}.` : base;
|
|
2277
|
+
}
|
|
2192
2278
|
function statusLabel(result) {
|
|
2193
2279
|
if (result.skipped) return "\u23ED\uFE0F Skipped (no script defined)";
|
|
2194
2280
|
return result.success ? "\u2705 Passed" : "\u274C Failed";
|
|
@@ -2265,14 +2351,16 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
2265
2351
|
cwd,
|
|
2266
2352
|
logs: pipelineResult.output,
|
|
2267
2353
|
maxAttempts,
|
|
2268
|
-
timeoutMs
|
|
2354
|
+
timeoutMs,
|
|
2355
|
+
approve: options.approve
|
|
2269
2356
|
});
|
|
2270
2357
|
const result = {
|
|
2271
2358
|
success: finalState.success,
|
|
2272
2359
|
attempts: finalState.attempts,
|
|
2273
2360
|
finalOutput: finalState.logs || pipelineResult.output,
|
|
2274
2361
|
appliedFix: finalState.appliedFix ?? void 0,
|
|
2275
|
-
error: finalState.success ? void 0 :
|
|
2362
|
+
error: finalState.success ? void 0 : failureMessage(maxAttempts, finalState.declinedFixes ?? 0, Boolean(finalState.appliedFix)),
|
|
2363
|
+
declinedFixes: finalState.declinedFixes ? finalState.declinedFixes : void 0,
|
|
2276
2364
|
modelUsed: finalState.modelUsed,
|
|
2277
2365
|
promptTokens: finalState.promptTokens,
|
|
2278
2366
|
completionTokens: finalState.completionTokens
|
|
@@ -2570,6 +2658,58 @@ function buildErrorJson(message) {
|
|
|
2570
2658
|
return { success: false, error: message };
|
|
2571
2659
|
}
|
|
2572
2660
|
|
|
2661
|
+
// src/approval.ts
|
|
2662
|
+
var import_readline = __toESM(require("readline"));
|
|
2663
|
+
var MAX_INVALID_ANSWERS = 5;
|
|
2664
|
+
function parseApprovalAnswer(raw) {
|
|
2665
|
+
const answer = raw.trim().toLowerCase();
|
|
2666
|
+
if (answer === "y" || answer === "yes") return "yes";
|
|
2667
|
+
if (answer === "" || answer === "n" || answer === "no") return "no";
|
|
2668
|
+
if (answer === "m" || answer === "note") return "note";
|
|
2669
|
+
return "invalid";
|
|
2670
|
+
}
|
|
2671
|
+
function createApprovalHandler(io) {
|
|
2672
|
+
const lines = import_readline.default.createInterface({ input: io.input, terminal: false })[Symbol.asyncIterator]();
|
|
2673
|
+
const ask = async (question) => {
|
|
2674
|
+
io.output.write(question);
|
|
2675
|
+
const next = await lines.next();
|
|
2676
|
+
return next.done ? void 0 : next.value;
|
|
2677
|
+
};
|
|
2678
|
+
return async (request) => {
|
|
2679
|
+
io.output.write(
|
|
2680
|
+
[
|
|
2681
|
+
"",
|
|
2682
|
+
`Proposed fix (attempt ${request.attempt}/${request.maxAttempts})`,
|
|
2683
|
+
` Root cause: ${request.rootCause}`,
|
|
2684
|
+
` Explanation: ${request.explanation}`,
|
|
2685
|
+
` Files: ${request.files.join(", ")}`,
|
|
2686
|
+
"",
|
|
2687
|
+
request.diff,
|
|
2688
|
+
"",
|
|
2689
|
+
""
|
|
2690
|
+
].join("\n")
|
|
2691
|
+
);
|
|
2692
|
+
for (let invalid = 0; invalid < MAX_INVALID_ANSWERS; ) {
|
|
2693
|
+
const raw = await ask("Apply this change? [y] yes [n] no [m] no, and leave a note for the AI (Enter = no): ");
|
|
2694
|
+
if (raw === void 0) {
|
|
2695
|
+
io.output.write("\nNo answer, so the change was not applied.\n");
|
|
2696
|
+
return { approved: false };
|
|
2697
|
+
}
|
|
2698
|
+
const answer = parseApprovalAnswer(raw);
|
|
2699
|
+
if (answer === "yes") return { approved: true };
|
|
2700
|
+
if (answer === "no") return { approved: false };
|
|
2701
|
+
if (answer === "note") {
|
|
2702
|
+
const note = (await ask("Note for the AI: "))?.trim();
|
|
2703
|
+
return note ? { approved: false, note } : { approved: false };
|
|
2704
|
+
}
|
|
2705
|
+
invalid++;
|
|
2706
|
+
io.output.write("Please answer y, n or m.\n");
|
|
2707
|
+
}
|
|
2708
|
+
io.output.write("Too many unclear answers, so the change was not applied.\n");
|
|
2709
|
+
return { approved: false };
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2573
2713
|
// src/summary.ts
|
|
2574
2714
|
var import_patcher = __toESM(require_dist6());
|
|
2575
2715
|
var import_shared2 = __toESM(require_dist4());
|
|
@@ -2693,7 +2833,7 @@ ${allPassed ? "\u2705 All checks passed" : "\u274C Issues found \u2014 run 'bugz
|
|
|
2693
2833
|
finish(1, json ? buildErrorJson(String(error.message || error)) : void 0);
|
|
2694
2834
|
}
|
|
2695
2835
|
});
|
|
2696
|
-
program.command("rescue").description("Detect build failures and automatically apply AI-generated fixes").option("-p, --path <dir>", "Path to the target project", ".").option("-n, --max-attempts <number>", "Maximum AI fix attempts", "3").option("-t, --timeout <seconds>", TIMEOUT_DESCRIPTION).option("--dry-run", "Analyse only \u2014 print what would be fixed without writing files", false).option("--print-prompt", "Print the exact prompt that would be sent to the AI model, then stop (nothing is sent, no files are written)").option("--json", JSON_DESCRIPTION).action(async (opts) => {
|
|
2836
|
+
program.command("rescue").description("Detect build failures and automatically apply AI-generated fixes").option("-p, --path <dir>", "Path to the target project", ".").option("-n, --max-attempts <number>", "Maximum AI fix attempts", "3").option("-t, --timeout <seconds>", TIMEOUT_DESCRIPTION).option("--dry-run", "Analyse only \u2014 print what would be fixed without writing files", false).option("--approve", "Show each proposed fix as a diff and ask before writing it (needs an interactive terminal)").option("--print-prompt", "Print the exact prompt that would be sent to the AI model, then stop (nothing is sent, no files are written)").option("--json", JSON_DESCRIPTION).action(async (opts) => {
|
|
2697
2837
|
const json = opts.json === true;
|
|
2698
2838
|
const printPrompt = opts.printPrompt === true;
|
|
2699
2839
|
if (json || printPrompt) routeLogsToStderr();
|
|
@@ -2703,6 +2843,15 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
2703
2843
|
const maxAttempts = (0, import_core.resolveMaxAttempts)(Number(opts.maxAttempts));
|
|
2704
2844
|
const timeoutSeconds = parseTimeout(opts.timeout);
|
|
2705
2845
|
const dryRun = opts.dryRun;
|
|
2846
|
+
let approve;
|
|
2847
|
+
if (opts.approve === true && !dryRun && !printPrompt) {
|
|
2848
|
+
if (!process.stdin.isTTY || !process.stderr.isTTY) {
|
|
2849
|
+
throw new Error(
|
|
2850
|
+
"--approve asks you to confirm each fix, which needs an interactive terminal, and there is none here (for example in CI, or when input is piped). Run it in a terminal, or leave out --approve."
|
|
2851
|
+
);
|
|
2852
|
+
}
|
|
2853
|
+
approve = createApprovalHandler({ input: process.stdin, output: process.stderr });
|
|
2854
|
+
}
|
|
2706
2855
|
const framework = (0, import_core.detectFramework)(cwd);
|
|
2707
2856
|
const packageManager = (0, import_core.detectPackageManager)(cwd);
|
|
2708
2857
|
console.log(`
|
|
@@ -2714,7 +2863,7 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
2714
2863
|
if (timeoutSeconds !== void 0) console.log(` Timeout: ${timeoutSeconds}s per command`);
|
|
2715
2864
|
if (dryRun) console.log(` Mode: DRY RUN (no files will be modified)`);
|
|
2716
2865
|
console.log();
|
|
2717
|
-
const result = await (0, import_core.orchestrateAndFix)({ cwd, maxAttempts, dryRun, timeoutSeconds, printPrompt });
|
|
2866
|
+
const result = await (0, import_core.orchestrateAndFix)({ cwd, maxAttempts, dryRun, timeoutSeconds, printPrompt, approve });
|
|
2718
2867
|
if (result.promptPreview !== void 0) {
|
|
2719
2868
|
if (json) {
|
|
2720
2869
|
finish(
|
|
@@ -2761,7 +2910,7 @@ program.command("protect").description("[Deprecated] Use 'hunt' instead").action
|
|
|
2761
2910
|
});
|
|
2762
2911
|
program.command("vibe").description("Select which AI model (brain) to use for resolving bugs").action(async () => {
|
|
2763
2912
|
const { getLocalConfig, saveLocalConfig } = await Promise.resolve().then(() => __toESM(require_dist()));
|
|
2764
|
-
const
|
|
2913
|
+
const readline2 = await import("readline");
|
|
2765
2914
|
const axios = (await import("axios")).default;
|
|
2766
2915
|
console.log(`
|
|
2767
2916
|
\u{1F9E0} BugZero Brain Selector`);
|
|
@@ -2804,7 +2953,7 @@ Current active model: \x1B[36m${currentModel}\x1B[0m
|
|
|
2804
2953
|
});
|
|
2805
2954
|
console.log(` [${popularModels.length + 1}] \u{1F58B}\uFE0F Custom Model (Type manually)`);
|
|
2806
2955
|
console.log();
|
|
2807
|
-
const rl =
|
|
2956
|
+
const rl = readline2.createInterface({
|
|
2808
2957
|
input: process.stdin,
|
|
2809
2958
|
output: process.stdout
|
|
2810
2959
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugzero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
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)",
|