bugzero 0.0.66 → 0.0.68
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 +13 -3
- package/dist/index.js +154 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,8 +110,8 @@ bugzero rescue
|
|
|
110
110
|
|
|
111
111
|
- **Framework detection.** Identifies Next.js, NestJS, Vite, Remix, Astro, SvelteKit, Nuxt, Angular, Create React App, or a plain TypeScript project from its config files and dependencies, and shows the result in the run banner.
|
|
112
112
|
- **Package manager detection.** Runs build, lint, and test with the tool your project actually uses — npm, pnpm, yarn, or bun. It checks the `packageManager` field in `package.json` first, then `pnpm-workspace.yaml` or a lockfile, and falls back to npm.
|
|
113
|
-
- **Script-aware validation.** Only runs the build, lint, and test scripts your `package.json` actually defines. A missing script is reported as skipped rather than failed, so a project without a `lint` script no longer shows a false lint failure. You can also give any step [your own command](#your-own-commands). Pointing `--path` at a directory with no `package.json` stops immediately with a clear error.
|
|
114
|
-
- **Error parsing.** Recognizes TypeScript compiler errors (file, line, column, message), ESLint errors, and
|
|
113
|
+
- **Script-aware validation.** Only runs the build, lint, and test scripts your `package.json` actually defines. A missing script is reported as skipped rather than failed, so a project without a `lint` script no longer shows a false lint failure. You can also give any step [your own command](#your-own-commands). Pointing `--path` at a directory with no `package.json` stops immediately with a clear error, unless `.bugzerorc` gives it [a command to run](#your-own-commands).
|
|
114
|
+
- **Error parsing.** Recognizes TypeScript compiler errors (file, line, column, message), ESLint errors, Jest failures and pytest failures to classify what broke and how many errors were found. Output in any other format is still passed to the model as raw logs.
|
|
115
115
|
|
|
116
116
|
### Integrations and output
|
|
117
117
|
|
|
@@ -369,10 +369,20 @@ To run something other than your `package.json` scripts, add `commands`:
|
|
|
369
369
|
- A command runs in your shell from the project folder, finds programs in `node_modules/.bin` as a script would, and is subject to `--timeout`. `hunt`, `rescue` and the GitHub Action all use it.
|
|
370
370
|
- Re-running only the failing test files still works when the `test` command is a single plain Jest or Vitest command such as `vitest run`. With any other command the full pipeline runs.
|
|
371
371
|
- The settings are read once, when a run starts. A step name or value BugZero does not understand stops the run before anything is executed.
|
|
372
|
-
-
|
|
372
|
+
- A folder with no `package.json`, such as a Python or Go project, is accepted once at least one step has a command (a command, not just `false`). Steps without one are skipped. `rescue` then shows the model any text file an error names, whatever its language.
|
|
373
373
|
|
|
374
374
|
These commands run on your machine exactly as written, so, as with `package.json` scripts, only run BugZero on projects you trust.
|
|
375
375
|
|
|
376
|
+
### Python projects
|
|
377
|
+
|
|
378
|
+
A folder with a `pyproject.toml`, `setup.py`, `setup.cfg`, `requirements.txt` (or `requirements-dev.txt` and the like), `Pipfile`, `pytest.ini` or `tox.ini` and no `package.json` is a Python project. BugZero shows it as `python`, and with no settings at all it runs your tests with `python -m pytest`, as long as the project clearly uses pytest (a `pytest.ini`, a `conftest.py`, a pytest section in its config, or pytest in its requirements) and pytest can really be run.
|
|
379
|
+
|
|
380
|
+
- The Python used is the project's own `.venv` or `venv` folder if it has one, otherwise `python3` (on Windows, `python`, then `py`).
|
|
381
|
+
- Nothing else is run by default. For a build or lint step, add `commands`, for example `{"commands": {"build": "mypy .", "lint": "ruff check ."}}`. A `test` command of your own replaces the default, and `"test": false` turns it off.
|
|
382
|
+
- If pytest is set up but cannot be run (it is not installed), BugZero stops and says so, rather than asking the model to fix a missing install.
|
|
383
|
+
- A folder that also has a `package.json` is treated as a Node.js project, as before.
|
|
384
|
+
- pytest output is understood: each failed test, and each file that could not be imported, counts as one error. That lets BugZero stop early when attempts are not getting anywhere. Re-running only the failing test files between attempts is still for Jest and Vitest.
|
|
385
|
+
|
|
376
386
|
---
|
|
377
387
|
|
|
378
388
|
## Reports
|
package/dist/index.js
CHANGED
|
@@ -1385,10 +1385,14 @@ var require_dist4 = __commonJS({
|
|
|
1385
1385
|
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
1386
1386
|
var index_exports = {};
|
|
1387
1387
|
__export(index_exports, {
|
|
1388
|
-
|
|
1388
|
+
defaultPythonCommands: () => defaultPythonCommands,
|
|
1389
|
+
detectPackageManager: () => detectPackageManager2,
|
|
1389
1390
|
detectTestRunner: () => detectTestRunner,
|
|
1390
1391
|
findFailingTestFiles: () => findFailingTestFiles,
|
|
1392
|
+
findPython: () => findPython,
|
|
1391
1393
|
getRunScriptCommand: () => getRunScriptCommand,
|
|
1394
|
+
hasPackageJson: () => hasPackageJson,
|
|
1395
|
+
isPythonProject: () => isPythonProject,
|
|
1392
1396
|
parseErrors: () => parseErrors,
|
|
1393
1397
|
planFocusedTests: () => planFocusedTests,
|
|
1394
1398
|
readScriptText: () => readScriptText,
|
|
@@ -1401,7 +1405,8 @@ var require_dist4 = __commonJS({
|
|
|
1401
1405
|
runStep: () => runStep,
|
|
1402
1406
|
runTests: () => runTests,
|
|
1403
1407
|
runValidationPipeline: () => runValidationPipeline,
|
|
1404
|
-
usableFocusedResult: () => usableFocusedResult
|
|
1408
|
+
usableFocusedResult: () => usableFocusedResult,
|
|
1409
|
+
usesPytest: () => usesPytest
|
|
1405
1410
|
});
|
|
1406
1411
|
module2.exports = __toCommonJS(index_exports);
|
|
1407
1412
|
var import_fs2 = __toESM2(require("fs"));
|
|
@@ -1417,7 +1422,7 @@ var require_dist4 = __commonJS({
|
|
|
1417
1422
|
{ file: "bun.lock", manager: "bun" },
|
|
1418
1423
|
{ file: "package-lock.json", manager: "npm" }
|
|
1419
1424
|
];
|
|
1420
|
-
function
|
|
1425
|
+
function detectPackageManager2(cwd = process.cwd()) {
|
|
1421
1426
|
try {
|
|
1422
1427
|
const pkgPath = import_path4.default.join(cwd, "package.json");
|
|
1423
1428
|
if (import_fs3.default.existsSync(pkgPath)) {
|
|
@@ -1501,6 +1506,9 @@ var require_dist4 = __commonJS({
|
|
|
1501
1506
|
clearTimeout(graceTimer);
|
|
1502
1507
|
}
|
|
1503
1508
|
}
|
|
1509
|
+
function hasPackageJson(cwd = process.cwd()) {
|
|
1510
|
+
return import_fs2.default.existsSync(import_path3.default.join(cwd, "package.json"));
|
|
1511
|
+
}
|
|
1504
1512
|
function readScripts(cwd = process.cwd()) {
|
|
1505
1513
|
try {
|
|
1506
1514
|
const pkgPath = import_path3.default.join(cwd, "package.json");
|
|
@@ -1527,13 +1535,14 @@ var require_dist4 = __commonJS({
|
|
|
1527
1535
|
const command = options?.commands?.[step];
|
|
1528
1536
|
if (command === false) return { success: true, output: "", skipped: true, disabled: true };
|
|
1529
1537
|
if (command !== void 0) return runCommand(command, cwd, { ...options, localBins: true });
|
|
1538
|
+
if (!hasPackageJson(cwd)) return { success: true, output: "", skipped: true, noCommand: true };
|
|
1530
1539
|
return runScript(step, cwd, options);
|
|
1531
1540
|
}
|
|
1532
1541
|
async function runScript(script, cwd, options) {
|
|
1533
1542
|
if (!readScripts(cwd).includes(script)) {
|
|
1534
1543
|
return { success: true, output: "", skipped: true };
|
|
1535
1544
|
}
|
|
1536
|
-
return runCommand(getRunScriptCommand(
|
|
1545
|
+
return runCommand(getRunScriptCommand(detectPackageManager2(cwd), script), cwd, options);
|
|
1537
1546
|
}
|
|
1538
1547
|
var runBuild = (cwd, options) => runStep("build", cwd, options);
|
|
1539
1548
|
var runLint = (cwd, options) => runStep("lint", cwd, options);
|
|
@@ -1542,6 +1551,8 @@ var require_dist4 = __commonJS({
|
|
|
1542
1551
|
var ESLINT_ERROR_RE = /^\s+(\d+):(\d+)\s+error\s+(.+)$/gm;
|
|
1543
1552
|
var JEST_FAIL_RE = /● (.+)/g;
|
|
1544
1553
|
var JEST_FILE_RE = /FAIL\s+([\w/\\.\-]+)/g;
|
|
1554
|
+
var PYTEST_LINE_RE = /^(?:FAILED|ERROR)[ \t]+(\S+?\.py)(?:::(.+?))?(?:[ \t]+-[ \t]+(.*))?$/gm;
|
|
1555
|
+
var ANSI_RE = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
1545
1556
|
function parseErrors(rawOutput) {
|
|
1546
1557
|
const output = rawOutput.replace(/\r\n/g, "\n");
|
|
1547
1558
|
const errors = [];
|
|
@@ -1579,6 +1590,16 @@ var require_dist4 = __commonJS({
|
|
|
1579
1590
|
});
|
|
1580
1591
|
}
|
|
1581
1592
|
if (errors.length > 0) return errors;
|
|
1593
|
+
for (const m of output.replace(ANSI_RE, "").matchAll(PYTEST_LINE_RE)) {
|
|
1594
|
+
const [raw, file, test, reason] = m;
|
|
1595
|
+
errors.push({
|
|
1596
|
+
type: "pytest",
|
|
1597
|
+
file,
|
|
1598
|
+
message: `${test ?? file}${reason ? ` - ${reason.trim()}` : ""}`,
|
|
1599
|
+
raw
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
if (errors.length > 0) return errors;
|
|
1582
1603
|
if (output.trim()) {
|
|
1583
1604
|
errors.push({
|
|
1584
1605
|
type: "unknown",
|
|
@@ -1596,6 +1617,7 @@ var require_dist4 = __commonJS({
|
|
|
1596
1617
|
async function runValidationPipeline(cwd, options) {
|
|
1597
1618
|
const targetCwd = cwd ?? process.cwd();
|
|
1598
1619
|
const scripts = readScripts(targetCwd);
|
|
1620
|
+
const nodeProject = hasPackageJson(targetCwd);
|
|
1599
1621
|
let ranAnyStep = false;
|
|
1600
1622
|
let turnedOff = false;
|
|
1601
1623
|
for (const { step, label, run } of STEPS) {
|
|
@@ -1606,7 +1628,9 @@ var require_dist4 = __commonJS({
|
|
|
1606
1628
|
continue;
|
|
1607
1629
|
}
|
|
1608
1630
|
if (command === void 0 && !scripts.includes(step)) {
|
|
1609
|
-
console.log(
|
|
1631
|
+
console.log(
|
|
1632
|
+
nodeProject ? `[BugZero] Skipping ${label}: no "${step}" script in package.json.` : `[BugZero] Skipping ${label}: no command for it in .bugzerorc.`
|
|
1633
|
+
);
|
|
1610
1634
|
continue;
|
|
1611
1635
|
}
|
|
1612
1636
|
ranAnyStep = true;
|
|
@@ -1618,7 +1642,7 @@ var require_dist4 = __commonJS({
|
|
|
1618
1642
|
}
|
|
1619
1643
|
if (!ranAnyStep) {
|
|
1620
1644
|
console.warn(
|
|
1621
|
-
turnedOff ? "[BugZero] Every step is turned off or has no script \u2014 nothing to validate." : "[BugZero] No build, lint, or test scripts found in package.json \u2014 nothing to validate."
|
|
1645
|
+
turnedOff ? "[BugZero] Every step is turned off or has no script \u2014 nothing to validate." : nodeProject ? "[BugZero] No build, lint, or test scripts found in package.json \u2014 nothing to validate." : "[BugZero] No build, lint, or test commands set in .bugzerorc \u2014 nothing to validate."
|
|
1622
1646
|
);
|
|
1623
1647
|
}
|
|
1624
1648
|
return { success: true, step: "none", output: "" };
|
|
@@ -1626,7 +1650,7 @@ var require_dist4 = __commonJS({
|
|
|
1626
1650
|
var import_fs32 = __toESM2(require("fs"));
|
|
1627
1651
|
var import_shared4 = require_dist2();
|
|
1628
1652
|
var MAX_FOCUSED_FILES = 10;
|
|
1629
|
-
var
|
|
1653
|
+
var ANSI_RE2 = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
1630
1654
|
var FAIL_LINE_RE = /^[ \t]*FAIL[ \t]+(?:\|[^|\n]*\|[ \t]+)?(\S+)/gm;
|
|
1631
1655
|
var TEST_FILE_RE = /\.(test|spec)\.[cm]?[jt]sx?$|(^|\/)__tests__\//;
|
|
1632
1656
|
var SAFE_PATH_RE = /^[A-Za-z0-9_@.+/-]+$/;
|
|
@@ -1641,7 +1665,7 @@ var require_dist4 = __commonJS({
|
|
|
1641
1665
|
return names.size === 1 ? [...names][0] : null;
|
|
1642
1666
|
}
|
|
1643
1667
|
function findFailingTestFiles(cwd, output) {
|
|
1644
|
-
const text = output.replace(
|
|
1668
|
+
const text = output.replace(ANSI_RE2, "").replace(/\r\n/g, "\n");
|
|
1645
1669
|
const files = [];
|
|
1646
1670
|
for (const match of text.matchAll(FAIL_LINE_RE)) {
|
|
1647
1671
|
const candidate = match[1].replace(/\\/g, "/").replace(/^\.\//, "");
|
|
@@ -1670,7 +1694,7 @@ var require_dist4 = __commonJS({
|
|
|
1670
1694
|
const files = findFailingTestFiles(cwd, output);
|
|
1671
1695
|
if (files.length === 0) return null;
|
|
1672
1696
|
if (command !== void 0) return { runner, files, command: `${command} ${quoted(files)}`, localBins: true };
|
|
1673
|
-
return { runner, files, command: scriptCommand(
|
|
1697
|
+
return { runner, files, command: scriptCommand(detectPackageManager2(cwd), files) };
|
|
1674
1698
|
}
|
|
1675
1699
|
function runFocusedTests(plan, cwd, options) {
|
|
1676
1700
|
return runCommand(plan.command, cwd, { ...options, localBins: plan.localBins });
|
|
@@ -1680,6 +1704,60 @@ var require_dist4 = __commonJS({
|
|
|
1680
1704
|
if (result.timedOut) return true;
|
|
1681
1705
|
return findFailingTestFiles(cwd, result.output).length > 0;
|
|
1682
1706
|
}
|
|
1707
|
+
var import_child_process2 = require("child_process");
|
|
1708
|
+
var import_fs4 = __toESM2(require("fs"));
|
|
1709
|
+
var import_path42 = __toESM2(require("path"));
|
|
1710
|
+
var MARKER_FILES = ["pyproject.toml", "setup.py", "setup.cfg", "Pipfile", "pytest.ini", "tox.ini"];
|
|
1711
|
+
function requirementsFiles(cwd) {
|
|
1712
|
+
try {
|
|
1713
|
+
return import_fs4.default.readdirSync(cwd).filter((name) => /^requirements([-_.].+)?\.txt$/i.test(name));
|
|
1714
|
+
} catch {
|
|
1715
|
+
return [];
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
function isPythonProject(cwd = process.cwd()) {
|
|
1719
|
+
return MARKER_FILES.some((file) => import_fs4.default.existsSync(import_path42.default.join(cwd, file))) || requirementsFiles(cwd).length > 0;
|
|
1720
|
+
}
|
|
1721
|
+
function readText(file) {
|
|
1722
|
+
try {
|
|
1723
|
+
return import_fs4.default.readFileSync(file, "utf-8");
|
|
1724
|
+
} catch {
|
|
1725
|
+
return "";
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
function usesPytest(cwd = process.cwd()) {
|
|
1729
|
+
const exists = (file) => import_fs4.default.existsSync(import_path42.default.join(cwd, file));
|
|
1730
|
+
if (exists("pytest.ini") || exists("conftest.py") || exists("tests/conftest.py") || exists("test/conftest.py")) return true;
|
|
1731
|
+
const pyproject = readText(import_path42.default.join(cwd, "pyproject.toml"));
|
|
1732
|
+
if (/\[tool\.pytest/.test(pyproject) || /["']pytest(?![\w.-])/.test(pyproject) || /^\s*pytest\s*=/m.test(pyproject)) return true;
|
|
1733
|
+
if (/^\[(?:tool:)?pytest\]/m.test(readText(import_path42.default.join(cwd, "setup.cfg")))) return true;
|
|
1734
|
+
if (/^\[(?:tool:)?pytest\]/m.test(readText(import_path42.default.join(cwd, "tox.ini")))) return true;
|
|
1735
|
+
if (/^\s*pytest\s*=/m.test(readText(import_path42.default.join(cwd, "Pipfile")))) return true;
|
|
1736
|
+
return requirementsFiles(cwd).some((name) => /^\s*pytest(?![\w.-])/im.test(readText(import_path42.default.join(cwd, name))));
|
|
1737
|
+
}
|
|
1738
|
+
function runsPytest(python, cwd) {
|
|
1739
|
+
const program2 = /[\\/]/.test(python) ? import_path42.default.resolve(cwd, python) : python;
|
|
1740
|
+
return (0, import_child_process2.spawnSync)(program2, ["-m", "pytest", "--version"], { cwd, stdio: "ignore", timeout: 2e4 }).status === 0;
|
|
1741
|
+
}
|
|
1742
|
+
function runsPython(command) {
|
|
1743
|
+
const result = (0, import_child_process2.spawnSync)(command, ["--version"], { stdio: "ignore", timeout: 5e3 });
|
|
1744
|
+
return result.status === 0;
|
|
1745
|
+
}
|
|
1746
|
+
function findPython(cwd, options = {}) {
|
|
1747
|
+
const platform = options.platform ?? process.platform;
|
|
1748
|
+
const works = options.works ?? runsPython;
|
|
1749
|
+
for (const folder of [".venv", "venv"]) {
|
|
1750
|
+
const interpreter = platform === "win32" ? import_path42.default.join(folder, "Scripts", "python.exe") : import_path42.default.join(folder, "bin", "python");
|
|
1751
|
+
if (import_fs4.default.existsSync(import_path42.default.join(cwd, interpreter))) return interpreter;
|
|
1752
|
+
}
|
|
1753
|
+
return (platform === "win32" ? ["python", "py"] : ["python3", "python"]).find((command) => works(command));
|
|
1754
|
+
}
|
|
1755
|
+
function defaultPythonCommands(cwd, options = {}) {
|
|
1756
|
+
if (hasPackageJson(cwd) || !isPythonProject(cwd) || !usesPytest(cwd)) return void 0;
|
|
1757
|
+
const python = findPython(cwd, options);
|
|
1758
|
+
if (python === void 0 || !(options.pytestWorks ?? runsPytest)(python, cwd)) return void 0;
|
|
1759
|
+
return { test: `${python} -m pytest` };
|
|
1760
|
+
}
|
|
1683
1761
|
}
|
|
1684
1762
|
});
|
|
1685
1763
|
|
|
@@ -1908,6 +1986,7 @@ Secret and protected files, .git, node_modules and build output are never shown
|
|
|
1908
1986
|
var MAX_LOG_CHARS = 2e4;
|
|
1909
1987
|
var MAX_FILE_CHARS = 2e4;
|
|
1910
1988
|
var MAX_CONTEXT_CHARS = 6e4;
|
|
1989
|
+
var CONTEXT_EXTENSIONS = /\.(?:tsx?|jsx?|json|css|html)$/i;
|
|
1911
1990
|
function truncateLogs(logs, maxChars = MAX_LOG_CHARS) {
|
|
1912
1991
|
if (logs.length <= maxChars) return logs;
|
|
1913
1992
|
const head = logs.slice(0, Math.floor(maxChars * 0.6));
|
|
@@ -1959,7 +2038,7 @@ ${tail}`;
|
|
|
1959
2038
|
while ((match = unixAbsRegex.exec(logs)) !== null) {
|
|
1960
2039
|
candidates.add(match[1].trim());
|
|
1961
2040
|
}
|
|
1962
|
-
const fallbackRegex = /(?:[a-zA-Z]:)?[a-zA-Z0-9_\-\/\\.]+\.
|
|
2041
|
+
const fallbackRegex = /(?:[a-zA-Z]:)?[a-zA-Z0-9_\-\/\\.]+\.[A-Za-z0-9]{1,10}/g;
|
|
1963
2042
|
const fallbackMatches = logs.match(fallbackRegex) || [];
|
|
1964
2043
|
for (const m of fallbackMatches) {
|
|
1965
2044
|
candidates.add(m.trim());
|
|
@@ -1983,9 +2062,16 @@ ${tail}`;
|
|
|
1983
2062
|
if ((0, import_shared4.projectRelativePaths)(cwd, filePath).some((rel) => rules.secretBlockedBy(rel) !== void 0)) return;
|
|
1984
2063
|
if (processedFiles.has(filePath)) return;
|
|
1985
2064
|
if (context.length >= MAX_CONTEXT_CHARS) return;
|
|
2065
|
+
const ordinary = CONTEXT_EXTENSIONS.test(filePath);
|
|
2066
|
+
if (!ordinary) {
|
|
2067
|
+
const paths = (0, import_shared4.projectRelativePaths)(cwd, filePath);
|
|
2068
|
+
if (paths.some((rel) => rules.readBlockedBy(rel) !== void 0 || rules.editBlockedBy(rel) !== void 0)) return;
|
|
2069
|
+
}
|
|
1986
2070
|
processedFiles.add(filePath);
|
|
1987
2071
|
try {
|
|
1988
|
-
|
|
2072
|
+
const bytes = import_fs2.default.readFileSync(filePath);
|
|
2073
|
+
if (!ordinary && bytes.includes(0)) return;
|
|
2074
|
+
let content = bytes.toString("utf-8");
|
|
1989
2075
|
if (content.length > MAX_FILE_CHARS) {
|
|
1990
2076
|
const omitted = content.length - MAX_FILE_CHARS;
|
|
1991
2077
|
content = `${content.slice(0, MAX_FILE_CHARS)}
|
|
@@ -2951,9 +3037,10 @@ var require_dist8 = __commonJS({
|
|
|
2951
3037
|
DEFAULT_PATIENCE: () => DEFAULT_PATIENCE,
|
|
2952
3038
|
REPORT_FILENAME: () => REPORT_FILENAME2,
|
|
2953
3039
|
detectFramework: () => detectFramework2,
|
|
2954
|
-
detectPackageManager: () =>
|
|
3040
|
+
detectPackageManager: () => import_analyzers4.detectPackageManager,
|
|
2955
3041
|
orchestrate: () => orchestrate2,
|
|
2956
3042
|
orchestrateAndFix: () => orchestrateAndFix2,
|
|
3043
|
+
projectPackageManager: () => projectPackageManager2,
|
|
2957
3044
|
resolveFocusTests: () => resolveFocusTests,
|
|
2958
3045
|
resolveMaxAttempts: () => resolveMaxAttempts2,
|
|
2959
3046
|
resolveMaxTokens: () => resolveMaxTokens2,
|
|
@@ -2965,6 +3052,7 @@ var require_dist8 = __commonJS({
|
|
|
2965
3052
|
module2.exports = __toCommonJS(index_exports);
|
|
2966
3053
|
var import_fs2 = __toESM2(require("fs"));
|
|
2967
3054
|
var import_path3 = __toESM2(require("path"));
|
|
3055
|
+
var import_analyzers = require_dist4();
|
|
2968
3056
|
function detectFramework2(cwd = process.cwd()) {
|
|
2969
3057
|
const has = (...files) => files.some((f) => import_fs2.default.existsSync(import_path3.default.join(cwd, f)));
|
|
2970
3058
|
if (has("next.config.js", "next.config.ts", "next.config.mjs")) return "nextjs";
|
|
@@ -2988,9 +3076,10 @@ var require_dist8 = __commonJS({
|
|
|
2988
3076
|
}
|
|
2989
3077
|
}
|
|
2990
3078
|
if (has("tsconfig.json")) return "typescript";
|
|
3079
|
+
if (!has("package.json") && (0, import_analyzers.isPythonProject)(cwd)) return "python";
|
|
2991
3080
|
return "unknown";
|
|
2992
3081
|
}
|
|
2993
|
-
var
|
|
3082
|
+
var import_analyzers3 = require_dist4();
|
|
2994
3083
|
var import_agents = require_dist7();
|
|
2995
3084
|
var import_shared22 = require_dist2();
|
|
2996
3085
|
var import_fs3 = __toESM2(require("fs"));
|
|
@@ -3191,12 +3280,23 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
3191
3280
|
}
|
|
3192
3281
|
return commands;
|
|
3193
3282
|
}
|
|
3283
|
+
var import_analyzers2 = require_dist4();
|
|
3194
3284
|
var import_fs22 = __toESM2(require("fs"));
|
|
3195
3285
|
var import_path22 = __toESM2(require("path"));
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3286
|
+
var hasPackageJson = (cwd) => import_fs22.default.existsSync(import_path22.default.join(cwd, "package.json"));
|
|
3287
|
+
function assertProject(cwd, commands = {}) {
|
|
3288
|
+
if (hasPackageJson(cwd)) return;
|
|
3289
|
+
if (Object.values(commands).some((command) => typeof command === "string")) return;
|
|
3290
|
+
if ((0, import_analyzers2.isPythonProject)(cwd)) {
|
|
3291
|
+
const why = (0, import_analyzers2.usesPytest)(cwd) ? "BugZero found pytest set up but could not run it (is it installed? A .venv or venv folder in the project is used when there is one). Install it, or" : "BugZero found no test setup it knows (pytest). To tell it how to check the project,";
|
|
3292
|
+
throw new Error(`No package.json found in ${cwd}. This looks like a Python project. ${why} set "commands" in .bugzerorc (see the README).`);
|
|
3293
|
+
}
|
|
3294
|
+
throw new Error(
|
|
3295
|
+
`No package.json found in ${cwd}. Point --path at a Node.js project, or, to check a project of another kind, set "commands" in .bugzerorc (see the README).`
|
|
3296
|
+
);
|
|
3297
|
+
}
|
|
3298
|
+
function projectPackageManager2(cwd) {
|
|
3299
|
+
return hasPackageJson(cwd) ? (0, import_analyzers2.detectPackageManager)(cwd) : "none";
|
|
3200
3300
|
}
|
|
3201
3301
|
var import_ai_provider = require_dist5();
|
|
3202
3302
|
var REPORT_FILENAME2 = "bugzero-report.md";
|
|
@@ -3212,28 +3312,40 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
3212
3312
|
const base = stoppedAfter !== void 0 ? `Stopped early: ${stoppedAfter} attempt${stoppedAfter === 1 ? "" : "s"} in a row made no progress (the errors did not get fewer and no later step was reached), so the remaining attempts were not used. Try a different model with 'bugzero vibe', or use --patience 0 to keep going regardless.` : `Max attempts (${maxAttempts}) reached without a successful build.`;
|
|
3213
3313
|
return declined > 0 ? `${base} You declined ${declined} proposed ${plural}.` : base;
|
|
3214
3314
|
}
|
|
3215
|
-
function projectCommands(configured) {
|
|
3216
|
-
const
|
|
3217
|
-
const
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3315
|
+
function projectCommands(cwd, configured) {
|
|
3316
|
+
const own = resolveCommands(configured);
|
|
3317
|
+
const defaults = own.test === void 0 ? (0, import_analyzers3.defaultPythonCommands)(cwd) ?? {} : {};
|
|
3318
|
+
const all = { ...defaults, ...own };
|
|
3319
|
+
return { commands: Object.keys(all).length === 0 ? void 0 : all, own, defaults };
|
|
3320
|
+
}
|
|
3321
|
+
function announceCommands({ own, defaults }) {
|
|
3322
|
+
const steps = ["build", "lint", "test"];
|
|
3323
|
+
const listed = steps.filter((step) => own[step] !== void 0).map((step) => `${step}: ${own[step] === false ? "off" : own[step]}`);
|
|
3324
|
+
if (listed.length > 0) console.log(`[BugZero] Commands from .bugzerorc: ${listed.join(" | ")}`);
|
|
3325
|
+
for (const step of steps) {
|
|
3326
|
+
if (own[step] !== void 0 || defaults[step] === void 0) continue;
|
|
3327
|
+
console.log(
|
|
3328
|
+
`[BugZero] Python project: running ${step === "test" ? "tests" : step} with ${defaults[step]} (a default; set "commands" in .bugzerorc to change it).`
|
|
3329
|
+
);
|
|
3330
|
+
}
|
|
3221
3331
|
}
|
|
3222
3332
|
function statusLabel(result) {
|
|
3223
3333
|
if (result.disabled) return "\u23ED\uFE0F Skipped (turned off in .bugzerorc)";
|
|
3334
|
+
if (result.noCommand) return "\u23ED\uFE0F Skipped (no command set)";
|
|
3224
3335
|
if (result.skipped) return "\u23ED\uFE0F Skipped (no script defined)";
|
|
3225
3336
|
return result.success ? "\u2705 Passed" : "\u274C Failed";
|
|
3226
3337
|
}
|
|
3227
3338
|
async function orchestrate2(options = {}) {
|
|
3228
3339
|
const cwd = options.cwd ?? process.cwd();
|
|
3229
|
-
assertNodeProject(cwd);
|
|
3230
3340
|
const timeoutMs = resolveTimeoutMs2(options.timeoutSeconds);
|
|
3231
|
-
const
|
|
3232
|
-
|
|
3341
|
+
const project = projectCommands(cwd, (0, import_config2.getLocalConfig)(cwd).commands);
|
|
3342
|
+
assertProject(cwd, project.commands);
|
|
3343
|
+
announceCommands(project);
|
|
3344
|
+
const stepOptions = { timeoutMs, commands: project.commands };
|
|
3233
3345
|
const [build, lint, test] = await Promise.all([
|
|
3234
|
-
(0,
|
|
3235
|
-
(0,
|
|
3236
|
-
(0,
|
|
3346
|
+
(0, import_analyzers3.runBuild)(cwd, stepOptions),
|
|
3347
|
+
(0, import_analyzers3.runLint)(cwd, stepOptions),
|
|
3348
|
+
(0, import_analyzers3.runTests)(cwd, stepOptions)
|
|
3237
3349
|
]);
|
|
3238
3350
|
await writeReport(cwd, "hunt", {
|
|
3239
3351
|
success: build.success && lint.success && test.success,
|
|
@@ -3246,7 +3358,6 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
3246
3358
|
}
|
|
3247
3359
|
async function orchestrateAndFix2(options = {}) {
|
|
3248
3360
|
const cwd = options.cwd ?? process.cwd();
|
|
3249
|
-
assertNodeProject(cwd);
|
|
3250
3361
|
const maxAttempts = resolveMaxAttempts2(options.maxAttempts);
|
|
3251
3362
|
const timeoutMs = resolveTimeoutMs2(options.timeoutSeconds);
|
|
3252
3363
|
const config = (0, import_config2.getLocalConfig)(cwd);
|
|
@@ -3255,7 +3366,10 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
3255
3366
|
const maxTokens = resolveMaxTokens2(options.maxTokens, config.maxTokens);
|
|
3256
3367
|
const tools = resolveTools(options.tools, config.tools);
|
|
3257
3368
|
const maxToolRequests = resolveMaxToolRequests2(options.maxToolRequests, config.maxToolRequests);
|
|
3258
|
-
const
|
|
3369
|
+
const project = projectCommands(cwd, config.commands);
|
|
3370
|
+
const commands = project.commands;
|
|
3371
|
+
assertProject(cwd, commands);
|
|
3372
|
+
announceCommands(project);
|
|
3259
3373
|
const announceTools = () => {
|
|
3260
3374
|
if (tools) {
|
|
3261
3375
|
console.log(
|
|
@@ -3266,7 +3380,7 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
3266
3380
|
}
|
|
3267
3381
|
};
|
|
3268
3382
|
console.log(`[BugZero] Running validation pipeline in: ${cwd}`);
|
|
3269
|
-
const pipelineResult = await (0,
|
|
3383
|
+
const pipelineResult = await (0, import_analyzers3.runValidationPipeline)(cwd, { timeoutMs, commands });
|
|
3270
3384
|
if (pipelineResult.success) {
|
|
3271
3385
|
console.log("[BugZero] Validation already passing \u2014 nothing to fix.");
|
|
3272
3386
|
if (options.printPrompt) {
|
|
@@ -3282,7 +3396,7 @@ Re-run without \`--dry-run\` to let BugZero attempt a fix.
|
|
|
3282
3396
|
});
|
|
3283
3397
|
return { success: true, attempts: 0, finalOutput: "" };
|
|
3284
3398
|
}
|
|
3285
|
-
const errors = (0,
|
|
3399
|
+
const errors = (0, import_analyzers3.parseErrors)(pipelineResult.output);
|
|
3286
3400
|
console.log(`[BugZero] Detected ${errors.length} error(s) (type: ${errors[0]?.type ?? "unknown"})`);
|
|
3287
3401
|
if (options.printPrompt) {
|
|
3288
3402
|
console.log("[BugZero] --print-prompt: showing the first prompt without sending it.");
|
|
@@ -3607,7 +3721,7 @@ ${rawOutput}
|
|
|
3607
3721
|
}
|
|
3608
3722
|
return spend;
|
|
3609
3723
|
}
|
|
3610
|
-
var
|
|
3724
|
+
var import_analyzers4 = require_dist4();
|
|
3611
3725
|
}
|
|
3612
3726
|
});
|
|
3613
3727
|
|
|
@@ -3860,7 +3974,7 @@ program.command("hunt").description("Run build, lint, and tests \u2014 report is
|
|
|
3860
3974
|
(0, import_config.loadProjectEnv)(cwd);
|
|
3861
3975
|
const timeoutSeconds = parseTimeout(opts.timeout);
|
|
3862
3976
|
const framework = (0, import_core.detectFramework)(cwd);
|
|
3863
|
-
const packageManager = (0, import_core.
|
|
3977
|
+
const packageManager = (0, import_core.projectPackageManager)(cwd);
|
|
3864
3978
|
console.log(`
|
|
3865
3979
|
\u{1F50D} BugZero \u2014 Analyzing project`);
|
|
3866
3980
|
console.log(` Path: ${cwd}`);
|
|
@@ -3871,7 +3985,10 @@ program.command("hunt").description("Run build, lint, and tests \u2014 report is
|
|
|
3871
3985
|
const { build, lint, test } = await (0, import_core.orchestrate)({ cwd, timeoutSeconds, aiReport: opts.aiReport });
|
|
3872
3986
|
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");
|
|
3873
3987
|
const label = (r) => {
|
|
3874
|
-
if (r.skipped)
|
|
3988
|
+
if (r.skipped) {
|
|
3989
|
+
if (r.disabled) return "\u23ED\uFE0F Skipped (turned off in .bugzerorc)";
|
|
3990
|
+
return r.noCommand ? "\u23ED\uFE0F Skipped (no command set)" : "\u23ED\uFE0F Skipped (no script)";
|
|
3991
|
+
}
|
|
3875
3992
|
return r.success ? "\u2705 Passed" : "\u274C Failed (see report)";
|
|
3876
3993
|
};
|
|
3877
3994
|
console.log(` Build: ${label(build)}`);
|
|
@@ -3923,7 +4040,7 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
3923
4040
|
approve = createApprovalHandler({ input: process.stdin, output: process.stderr });
|
|
3924
4041
|
}
|
|
3925
4042
|
const framework = (0, import_core.detectFramework)(cwd);
|
|
3926
|
-
const packageManager = (0, import_core.
|
|
4043
|
+
const packageManager = (0, import_core.projectPackageManager)(cwd);
|
|
3927
4044
|
console.log(`
|
|
3928
4045
|
\u{1F916} BugZero Fix`);
|
|
3929
4046
|
console.log(` Path: ${cwd}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugzero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.68",
|
|
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)",
|