bugzero 0.0.13 → 0.0.16
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/.turbo/turbo-build.log +4 -4
- package/README.md +12 -0
- package/dist/index.js +177 -5
- package/package.json +1 -1
- package/src/index.ts +11 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> bugzero@0.0.
|
|
2
|
+
> bugzero@0.0.16 build D:\WD projects\OpsPilot\packages\cli
|
|
3
3
|
> tsup src/index.ts --format cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
[34mCLI[39m tsup v8.5.1
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist\index.js [22m[
|
|
11
|
-
[32mCJS[39m ⚡️ Build success in
|
|
10
|
+
[32mCJS[39m [1mdist\index.js [22m[32m56.82 KB[39m
|
|
11
|
+
[32mCJS[39m ⚡️ Build success in 170ms
|
|
12
12
|
[34mDTS[39m Build start
|
|
13
|
-
[32mDTS[39m ⚡️ Build success in
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 1192ms
|
|
14
14
|
[32mDTS[39m [1mdist\index.d.ts [22m[32m20.00 B[39m
|
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ bugzero rescue
|
|
|
77
77
|
| Error type parsing | Parses TypeScript, ESLint, and Jest error formats |
|
|
78
78
|
| Dry-run mode | Analyze and report without writing any files |
|
|
79
79
|
| Local model config | Save preferred model to `.bugzerorc` per project |
|
|
80
|
+
| Markdown Reports | Automatically generates a detailed `bugzero-report.md` listing error logs, model name, token usage, and search/replace code diffs |
|
|
80
81
|
|
|
81
82
|
---
|
|
82
83
|
|
|
@@ -165,6 +166,17 @@ This file is created automatically when you run `bugzero vibe`.
|
|
|
165
166
|
|
|
166
167
|
---
|
|
167
168
|
|
|
169
|
+
## Reports
|
|
170
|
+
|
|
171
|
+
Every time you run `bugzero hunt` or `bugzero rescue`, a detailed Markdown report is automatically generated at `bugzero-report.md` in the target project directory. This report includes:
|
|
172
|
+
- **Pipeline Summary:** Clear status checklist of your project's Build, Lint, and Test suites.
|
|
173
|
+
- **Detailed Error Outputs:** Full error logs from any failing checks.
|
|
174
|
+
- **AI Brain Details:** The exact OpenRouter model used.
|
|
175
|
+
- **Token Usage:** Accumulated prompt and completion tokens used for the run.
|
|
176
|
+
- **Applied Fixes (for rescue):** The root cause, explanation, and before/after search-replace code diffs of any patches applied.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
168
180
|
## Development Setup
|
|
169
181
|
|
|
170
182
|
Clone the repository and install dependencies. This project uses a pnpm monorepo managed by Turborepo.
|
package/dist/index.js
CHANGED
|
@@ -643,7 +643,11 @@ var require_dist3 = __commonJS({
|
|
|
643
643
|
if (response.data?.error) {
|
|
644
644
|
throw new Error(response.data.error.message || JSON.stringify(response.data.error));
|
|
645
645
|
}
|
|
646
|
-
return
|
|
646
|
+
return {
|
|
647
|
+
content: response.data.choices[0].message.content,
|
|
648
|
+
model,
|
|
649
|
+
usage: response.data.usage
|
|
650
|
+
};
|
|
647
651
|
} catch (error) {
|
|
648
652
|
let msg = error.message;
|
|
649
653
|
if (error.response?.data?.error?.message) {
|
|
@@ -877,6 +881,21 @@ var require_dist6 = __commonJS({
|
|
|
877
881
|
success: (0, import_langgraph.Annotation)({
|
|
878
882
|
reducer: (_, value) => value,
|
|
879
883
|
default: () => false
|
|
884
|
+
}),
|
|
885
|
+
/** Model used for the repair */
|
|
886
|
+
modelUsed: (0, import_langgraph.Annotation)({
|
|
887
|
+
reducer: (_, value) => value,
|
|
888
|
+
default: () => ""
|
|
889
|
+
}),
|
|
890
|
+
/** Total prompt tokens used */
|
|
891
|
+
promptTokens: (0, import_langgraph.Annotation)({
|
|
892
|
+
reducer: (old, value) => old + value,
|
|
893
|
+
default: () => 0
|
|
894
|
+
}),
|
|
895
|
+
/** Total completion tokens used */
|
|
896
|
+
completionTokens: (0, import_langgraph.Annotation)({
|
|
897
|
+
reducer: (old, value) => old + value,
|
|
898
|
+
default: () => 0
|
|
880
899
|
})
|
|
881
900
|
});
|
|
882
901
|
var import_ai_provider = require_dist3();
|
|
@@ -890,7 +909,8 @@ var require_dist6 = __commonJS({
|
|
|
890
909
|
[BugZero] Attempt ${state.attempts + 1}/${state.maxAttempts} \u2014 asking AI\u2026`
|
|
891
910
|
);
|
|
892
911
|
const prompt = (0, import_prompts.buildAnalysisPrompt)(state.logs, state.cwd);
|
|
893
|
-
const
|
|
912
|
+
const result = await provider.invoke(prompt, { cwd: state.cwd });
|
|
913
|
+
const response = result.content;
|
|
894
914
|
let fixSuggestion = null;
|
|
895
915
|
try {
|
|
896
916
|
const cleaned = response.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
|
|
@@ -906,7 +926,10 @@ var require_dist6 = __commonJS({
|
|
|
906
926
|
return {
|
|
907
927
|
analysis: response,
|
|
908
928
|
fixSuggestion,
|
|
909
|
-
attempts: state.attempts + 1
|
|
929
|
+
attempts: state.attempts + 1,
|
|
930
|
+
modelUsed: result.model,
|
|
931
|
+
promptTokens: result.usage?.prompt_tokens ?? 0,
|
|
932
|
+
completionTokens: result.usage?.completion_tokens ?? 0
|
|
910
933
|
};
|
|
911
934
|
}
|
|
912
935
|
async function applyFixNode(state) {
|
|
@@ -1036,6 +1059,8 @@ var require_dist7 = __commonJS({
|
|
|
1036
1059
|
}
|
|
1037
1060
|
var import_analyzers = require_dist2();
|
|
1038
1061
|
var import_agents = require_dist6();
|
|
1062
|
+
var import_fs2 = __toESM2(require("fs"));
|
|
1063
|
+
var import_path22 = __toESM2(require("path"));
|
|
1039
1064
|
async function orchestrate2(options = {}) {
|
|
1040
1065
|
const cwd = options.cwd ?? process.cwd();
|
|
1041
1066
|
const [build, lint, test] = await Promise.all([
|
|
@@ -1043,6 +1068,12 @@ var require_dist7 = __commonJS({
|
|
|
1043
1068
|
(0, import_analyzers.runLint)(cwd),
|
|
1044
1069
|
(0, import_analyzers.runTests)(cwd)
|
|
1045
1070
|
]);
|
|
1071
|
+
writeReport(cwd, "hunt", {
|
|
1072
|
+
success: build.success && lint.success && test.success,
|
|
1073
|
+
build,
|
|
1074
|
+
lint,
|
|
1075
|
+
test
|
|
1076
|
+
});
|
|
1046
1077
|
return { build, lint, test };
|
|
1047
1078
|
}
|
|
1048
1079
|
async function orchestrateAndFix2(options = {}) {
|
|
@@ -1052,12 +1083,25 @@ var require_dist7 = __commonJS({
|
|
|
1052
1083
|
const pipelineResult = await (0, import_analyzers.runValidationPipeline)(cwd);
|
|
1053
1084
|
if (pipelineResult.success) {
|
|
1054
1085
|
console.log("[BugZero] Validation already passing \u2014 nothing to fix.");
|
|
1086
|
+
writeReport(cwd, "rescue", {
|
|
1087
|
+
success: true,
|
|
1088
|
+
attempts: 0,
|
|
1089
|
+
maxAttempts,
|
|
1090
|
+
rawOutput: ""
|
|
1091
|
+
});
|
|
1055
1092
|
return { success: true, attempts: 0, finalOutput: "" };
|
|
1056
1093
|
}
|
|
1057
1094
|
const errors = (0, import_analyzers.parseErrors)(pipelineResult.output);
|
|
1058
1095
|
console.log(`[BugZero] Detected ${errors.length} error(s) (type: ${errors[0]?.type ?? "unknown"})`);
|
|
1059
1096
|
if (options.dryRun) {
|
|
1060
1097
|
console.log("[BugZero] Dry-run mode \u2014 skipping AI fix.");
|
|
1098
|
+
writeReport(cwd, "rescue", {
|
|
1099
|
+
success: false,
|
|
1100
|
+
attempts: 0,
|
|
1101
|
+
maxAttempts,
|
|
1102
|
+
error: "Dry-run: analysis complete, no files modified.",
|
|
1103
|
+
rawOutput: pipelineResult.output
|
|
1104
|
+
});
|
|
1061
1105
|
return {
|
|
1062
1106
|
success: false,
|
|
1063
1107
|
attempts: 0,
|
|
@@ -1072,13 +1116,128 @@ var require_dist7 = __commonJS({
|
|
|
1072
1116
|
attempts: 0,
|
|
1073
1117
|
success: false
|
|
1074
1118
|
});
|
|
1075
|
-
|
|
1119
|
+
const result = {
|
|
1076
1120
|
success: finalState.success,
|
|
1077
1121
|
attempts: finalState.attempts,
|
|
1078
1122
|
finalOutput: finalState.logs || pipelineResult.output,
|
|
1079
1123
|
appliedFix: finalState.fixSuggestion ?? void 0,
|
|
1080
|
-
error: finalState.success ? void 0 : `Max attempts (${maxAttempts}) reached without a successful build
|
|
1124
|
+
error: finalState.success ? void 0 : `Max attempts (${maxAttempts}) reached without a successful build.`,
|
|
1125
|
+
modelUsed: finalState.modelUsed,
|
|
1126
|
+
promptTokens: finalState.promptTokens,
|
|
1127
|
+
completionTokens: finalState.completionTokens
|
|
1081
1128
|
};
|
|
1129
|
+
writeReport(cwd, "rescue", {
|
|
1130
|
+
success: result.success,
|
|
1131
|
+
attempts: result.attempts,
|
|
1132
|
+
maxAttempts,
|
|
1133
|
+
appliedFix: result.appliedFix,
|
|
1134
|
+
error: result.error,
|
|
1135
|
+
rawOutput: result.finalOutput,
|
|
1136
|
+
modelUsed: result.modelUsed,
|
|
1137
|
+
promptTokens: result.promptTokens,
|
|
1138
|
+
completionTokens: result.completionTokens
|
|
1139
|
+
});
|
|
1140
|
+
return result;
|
|
1141
|
+
}
|
|
1142
|
+
function writeReport(cwd, type, data) {
|
|
1143
|
+
const reportPath = import_path22.default.join(cwd, "bugzero-report.md");
|
|
1144
|
+
let content = "";
|
|
1145
|
+
if (type === "hunt") {
|
|
1146
|
+
const { build, lint, test } = data;
|
|
1147
|
+
content = `# \u{1F50D} BugZero Hunt Report
|
|
1148
|
+
|
|
1149
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1150
|
+
**Project Path:** \`${cwd}\`
|
|
1151
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1152
|
+
|
|
1153
|
+
## \u{1F4CA} Status Summary
|
|
1154
|
+
- **Build:** ${build.success ? "\u2705 Passed" : "\u274C Failed"}
|
|
1155
|
+
- **Lint:** ${lint.success ? "\u2705 Passed" : "\u274C Failed"}
|
|
1156
|
+
- **Test:** ${test.success ? "\u2705 Passed" : "\u274C Failed"}
|
|
1157
|
+
|
|
1158
|
+
`;
|
|
1159
|
+
if (!build.success || !lint.success || !test.success) {
|
|
1160
|
+
content += `## \u274C Failed Checks & Error Output
|
|
1161
|
+
|
|
1162
|
+
`;
|
|
1163
|
+
if (!build.success) {
|
|
1164
|
+
content += `### \u{1F7E5} Build Failure
|
|
1165
|
+
\`\`\`text
|
|
1166
|
+
${build.output}
|
|
1167
|
+
\`\`\`
|
|
1168
|
+
|
|
1169
|
+
`;
|
|
1170
|
+
}
|
|
1171
|
+
if (!lint.success) {
|
|
1172
|
+
content += `### \u{1F7E8} Lint Failure
|
|
1173
|
+
\`\`\`text
|
|
1174
|
+
${lint.output}
|
|
1175
|
+
\`\`\`
|
|
1176
|
+
|
|
1177
|
+
`;
|
|
1178
|
+
}
|
|
1179
|
+
if (!test.success) {
|
|
1180
|
+
content += `### \u{1F7E6} Test Failure
|
|
1181
|
+
\`\`\`text
|
|
1182
|
+
${test.output}
|
|
1183
|
+
\`\`\`
|
|
1184
|
+
|
|
1185
|
+
`;
|
|
1186
|
+
}
|
|
1187
|
+
content += `\u{1F4A1} *Run \`bugzero rescue\` to automatically fix these issues.*`;
|
|
1188
|
+
} else {
|
|
1189
|
+
content += `\u{1F389} **All checks passed! Your project is in perfect shape.**`;
|
|
1190
|
+
}
|
|
1191
|
+
} else {
|
|
1192
|
+
const { success, attempts, maxAttempts, appliedFix, error, rawOutput, modelUsed, promptTokens, completionTokens } = data;
|
|
1193
|
+
content = `# \u{1F916} BugZero Rescue Report
|
|
1194
|
+
|
|
1195
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1196
|
+
**Project Path:** \`${cwd}\`
|
|
1197
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1198
|
+
|
|
1199
|
+
## \u{1F4CA} Repair Summary
|
|
1200
|
+
- **Status:** ${success ? "\u2705 Fixed successfully!" : "\u274C Could not repair automatically"}
|
|
1201
|
+
- **Attempts:** ${attempts} / ${maxAttempts}
|
|
1202
|
+
- **AI Brain (Model):** \`${modelUsed || "unknown"}\`
|
|
1203
|
+
- **Token Usage:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
1204
|
+
|
|
1205
|
+
`;
|
|
1206
|
+
if (success && appliedFix) {
|
|
1207
|
+
content += `## \u{1F6E0}\uFE0F Applied Solution
|
|
1208
|
+
- **Target File:** \`${appliedFix.filePath}\`
|
|
1209
|
+
- **Root Cause:** ${appliedFix.rootCause}
|
|
1210
|
+
- **Explanation:** ${appliedFix.explanation}
|
|
1211
|
+
|
|
1212
|
+
### \u{1F4DD} Code Changes
|
|
1213
|
+
**Search (Before):**
|
|
1214
|
+
\`\`\`typescript
|
|
1215
|
+
${appliedFix.search}
|
|
1216
|
+
\`\`\`
|
|
1217
|
+
|
|
1218
|
+
**Replace (After):**
|
|
1219
|
+
\`\`\`typescript
|
|
1220
|
+
${appliedFix.replace}
|
|
1221
|
+
\`\`\`
|
|
1222
|
+
`;
|
|
1223
|
+
} else {
|
|
1224
|
+
content += `## \u274C Failed to Repair
|
|
1225
|
+
**Reason:** ${error || "Max attempts reached without finding a solution."}
|
|
1226
|
+
|
|
1227
|
+
### \u{1F7E5} Unresolved Errors & Logs
|
|
1228
|
+
\`\`\`text
|
|
1229
|
+
${rawOutput}
|
|
1230
|
+
\`\`\`
|
|
1231
|
+
`;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
try {
|
|
1235
|
+
import_fs2.default.writeFileSync(reportPath, content, "utf-8");
|
|
1236
|
+
console.log(`
|
|
1237
|
+
\u{1F4DD} Generated report at: bugzero-report.md`);
|
|
1238
|
+
} catch (e) {
|
|
1239
|
+
console.error(`\u26A0\uFE0F Failed to write report file: ${e.message}`);
|
|
1240
|
+
}
|
|
1082
1241
|
}
|
|
1083
1242
|
}
|
|
1084
1243
|
});
|
|
@@ -1142,6 +1301,10 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
1142
1301
|
console.log("\n\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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
1143
1302
|
if (result.success) {
|
|
1144
1303
|
console.log(`\u2705 Build fixed after ${result.attempts} attempt(s)!`);
|
|
1304
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1305
|
+
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1306
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1307
|
+
}
|
|
1145
1308
|
if (result.appliedFix) {
|
|
1146
1309
|
console.log(` File: ${result.appliedFix.filePath}`);
|
|
1147
1310
|
console.log(` Reason: ${result.appliedFix.explanation}`);
|
|
@@ -1149,7 +1312,16 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
1149
1312
|
}
|
|
1150
1313
|
} else {
|
|
1151
1314
|
console.log(`\u274C Could not fix build after ${result.attempts} attempt(s).`);
|
|
1315
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1316
|
+
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1317
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1318
|
+
}
|
|
1152
1319
|
if (result.error) console.log(` ${result.error}`);
|
|
1320
|
+
console.log(`
|
|
1321
|
+
\u2500\u2500 Unresolved Error Output \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
1322
|
+
console.log(result.finalOutput);
|
|
1323
|
+
console.log(`\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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1324
|
+
`);
|
|
1153
1325
|
}
|
|
1154
1326
|
console.log();
|
|
1155
1327
|
process.exit(result.success ? 0 : 1);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -82,6 +82,10 @@ program
|
|
|
82
82
|
console.log("\n──────────────────────────────────────────────");
|
|
83
83
|
if (result.success) {
|
|
84
84
|
console.log(`✅ Build fixed after ${result.attempts} attempt(s)!`);
|
|
85
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
86
|
+
if (result.promptTokens !== undefined && result.completionTokens !== undefined) {
|
|
87
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
88
|
+
}
|
|
85
89
|
if (result.appliedFix) {
|
|
86
90
|
console.log(` File: ${result.appliedFix.filePath}`);
|
|
87
91
|
console.log(` Reason: ${result.appliedFix.explanation}`);
|
|
@@ -89,7 +93,14 @@ program
|
|
|
89
93
|
}
|
|
90
94
|
} else {
|
|
91
95
|
console.log(`❌ Could not fix build after ${result.attempts} attempt(s).`);
|
|
96
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
97
|
+
if (result.promptTokens !== undefined && result.completionTokens !== undefined) {
|
|
98
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
99
|
+
}
|
|
92
100
|
if (result.error) console.log(` ${result.error}`);
|
|
101
|
+
console.log(`\n── Unresolved Error Output ────────────────────────`);
|
|
102
|
+
console.log(result.finalOutput);
|
|
103
|
+
console.log(`───────────────────────────────────────────────────\n`);
|
|
93
104
|
}
|
|
94
105
|
console.log();
|
|
95
106
|
|