bugzero 0.0.13 → 0.0.17
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 +290 -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.17 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[32m63.10 KB[39m
|
|
11
|
+
[32mCJS[39m ⚡️ Build success in 102ms
|
|
12
12
|
[34mDTS[39m Build start
|
|
13
|
-
[32mDTS[39m ⚡️ Build success in
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 1876ms
|
|
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 Markdown report and opens it in your IDE (VS Code, Cursor, Windsurf, Sublime) as an unsaved editor tab, giving you the choice to save or discard it. |
|
|
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 generated and automatically opened in your IDE (VS Code, Cursor, Windsurf, or Sublime Text) as an unsaved editor tab. This avoids polluting your project workspace and gives you the choice to save it or discard it. The 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,7 @@ var require_dist7 = __commonJS({
|
|
|
1036
1059
|
}
|
|
1037
1060
|
var import_analyzers = require_dist2();
|
|
1038
1061
|
var import_agents = require_dist6();
|
|
1062
|
+
var import_ai_provider = require_dist3();
|
|
1039
1063
|
async function orchestrate2(options = {}) {
|
|
1040
1064
|
const cwd = options.cwd ?? process.cwd();
|
|
1041
1065
|
const [build, lint, test] = await Promise.all([
|
|
@@ -1043,6 +1067,12 @@ var require_dist7 = __commonJS({
|
|
|
1043
1067
|
(0, import_analyzers.runLint)(cwd),
|
|
1044
1068
|
(0, import_analyzers.runTests)(cwd)
|
|
1045
1069
|
]);
|
|
1070
|
+
await writeReport(cwd, "hunt", {
|
|
1071
|
+
success: build.success && lint.success && test.success,
|
|
1072
|
+
build,
|
|
1073
|
+
lint,
|
|
1074
|
+
test
|
|
1075
|
+
});
|
|
1046
1076
|
return { build, lint, test };
|
|
1047
1077
|
}
|
|
1048
1078
|
async function orchestrateAndFix2(options = {}) {
|
|
@@ -1052,12 +1082,25 @@ var require_dist7 = __commonJS({
|
|
|
1052
1082
|
const pipelineResult = await (0, import_analyzers.runValidationPipeline)(cwd);
|
|
1053
1083
|
if (pipelineResult.success) {
|
|
1054
1084
|
console.log("[BugZero] Validation already passing \u2014 nothing to fix.");
|
|
1085
|
+
await writeReport(cwd, "rescue", {
|
|
1086
|
+
success: true,
|
|
1087
|
+
attempts: 0,
|
|
1088
|
+
maxAttempts,
|
|
1089
|
+
rawOutput: ""
|
|
1090
|
+
});
|
|
1055
1091
|
return { success: true, attempts: 0, finalOutput: "" };
|
|
1056
1092
|
}
|
|
1057
1093
|
const errors = (0, import_analyzers.parseErrors)(pipelineResult.output);
|
|
1058
1094
|
console.log(`[BugZero] Detected ${errors.length} error(s) (type: ${errors[0]?.type ?? "unknown"})`);
|
|
1059
1095
|
if (options.dryRun) {
|
|
1060
1096
|
console.log("[BugZero] Dry-run mode \u2014 skipping AI fix.");
|
|
1097
|
+
await writeReport(cwd, "rescue", {
|
|
1098
|
+
success: false,
|
|
1099
|
+
attempts: 0,
|
|
1100
|
+
maxAttempts,
|
|
1101
|
+
error: "Dry-run: analysis complete, no files modified.",
|
|
1102
|
+
rawOutput: pipelineResult.output
|
|
1103
|
+
});
|
|
1061
1104
|
return {
|
|
1062
1105
|
success: false,
|
|
1063
1106
|
attempts: 0,
|
|
@@ -1072,13 +1115,242 @@ var require_dist7 = __commonJS({
|
|
|
1072
1115
|
attempts: 0,
|
|
1073
1116
|
success: false
|
|
1074
1117
|
});
|
|
1075
|
-
|
|
1118
|
+
const result = {
|
|
1076
1119
|
success: finalState.success,
|
|
1077
1120
|
attempts: finalState.attempts,
|
|
1078
1121
|
finalOutput: finalState.logs || pipelineResult.output,
|
|
1079
1122
|
appliedFix: finalState.fixSuggestion ?? void 0,
|
|
1080
|
-
error: finalState.success ? void 0 : `Max attempts (${maxAttempts}) reached without a successful build
|
|
1123
|
+
error: finalState.success ? void 0 : `Max attempts (${maxAttempts}) reached without a successful build.`,
|
|
1124
|
+
modelUsed: finalState.modelUsed,
|
|
1125
|
+
promptTokens: finalState.promptTokens,
|
|
1126
|
+
completionTokens: finalState.completionTokens
|
|
1081
1127
|
};
|
|
1128
|
+
await writeReport(cwd, "rescue", {
|
|
1129
|
+
success: result.success,
|
|
1130
|
+
attempts: result.attempts,
|
|
1131
|
+
maxAttempts,
|
|
1132
|
+
appliedFix: result.appliedFix,
|
|
1133
|
+
error: result.error,
|
|
1134
|
+
rawOutput: result.finalOutput,
|
|
1135
|
+
modelUsed: result.modelUsed,
|
|
1136
|
+
promptTokens: result.promptTokens,
|
|
1137
|
+
completionTokens: result.completionTokens
|
|
1138
|
+
});
|
|
1139
|
+
return result;
|
|
1140
|
+
}
|
|
1141
|
+
async function writeReport(cwd, type, data) {
|
|
1142
|
+
let content = "";
|
|
1143
|
+
const provider = new import_ai_provider.OpenRouterProvider();
|
|
1144
|
+
if (type === "hunt") {
|
|
1145
|
+
const { build, lint, test } = data;
|
|
1146
|
+
if (!build.success || !lint.success || !test.success) {
|
|
1147
|
+
let logs = "";
|
|
1148
|
+
if (!build.success) logs += `[BUILD FAILURE]
|
|
1149
|
+
${build.output}
|
|
1150
|
+
|
|
1151
|
+
`;
|
|
1152
|
+
if (!lint.success) logs += `[LINT FAILURE]
|
|
1153
|
+
${lint.output}
|
|
1154
|
+
|
|
1155
|
+
`;
|
|
1156
|
+
if (!test.success) logs += `[TEST FAILURE]
|
|
1157
|
+
${test.output}
|
|
1158
|
+
|
|
1159
|
+
`;
|
|
1160
|
+
console.log("[BugZero] Calling AI to diagnose errors and write report...");
|
|
1161
|
+
const prompt = `You are an expert software engineer assistant. Below is the error output from a project's build, lint, and test checks.
|
|
1162
|
+
Please analyze the errors and generate a professional, beautifully formatted Markdown report summarizing:
|
|
1163
|
+
1. **Diagnosis:** Clear explanation of what failed and why.
|
|
1164
|
+
2. **Root Cause:** The underlying issue in the code/config.
|
|
1165
|
+
3. **Action Plan:** Step-by-step instructions on what files need to be modified and what exact changes to make.
|
|
1166
|
+
|
|
1167
|
+
Failed Checks Logs:
|
|
1168
|
+
${logs}
|
|
1169
|
+
|
|
1170
|
+
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1171
|
+
try {
|
|
1172
|
+
const result = await provider.invoke(prompt, { cwd });
|
|
1173
|
+
content = result.content;
|
|
1174
|
+
content += `
|
|
1175
|
+
|
|
1176
|
+
---
|
|
1177
|
+
### \u{1F50D} BugZero Hunt Metadata
|
|
1178
|
+
- **AI Brain (Model) used for Diagnosis:** \`${result.model || "unknown"}\`
|
|
1179
|
+
- **Token Usage for Diagnosis:** ${result.usage ? `Prompt: **${result.usage.prompt_tokens}** | Completion: **${result.usage.completion_tokens}** | Total: **${result.usage.total_tokens}**` : "*N/A*"}`;
|
|
1180
|
+
} catch (e) {
|
|
1181
|
+
content = `# \u{1F50D} BugZero Hunt Report
|
|
1182
|
+
|
|
1183
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1184
|
+
**Project Path:** \`${cwd}\`
|
|
1185
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1186
|
+
|
|
1187
|
+
## \u{1F4CA} Status Summary
|
|
1188
|
+
- **Build:** ${build.success ? "\u2705 Passed" : "\u274C Failed"}
|
|
1189
|
+
- **Lint:** ${lint.success ? "\u2705 Passed" : "\u274C Failed"}
|
|
1190
|
+
- **Test:** ${test.success ? "\u2705 Passed" : "\u274C Failed"}
|
|
1191
|
+
|
|
1192
|
+
## \u274C Failed Checks & Error Output
|
|
1193
|
+
${logs}
|
|
1194
|
+
`;
|
|
1195
|
+
}
|
|
1196
|
+
} else {
|
|
1197
|
+
content = `# \u{1F50D} BugZero Hunt Report
|
|
1198
|
+
|
|
1199
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1200
|
+
**Project Path:** \`${cwd}\`
|
|
1201
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1202
|
+
|
|
1203
|
+
## \u{1F4CA} Status Summary
|
|
1204
|
+
- **Build:** \u2705 Passed
|
|
1205
|
+
- **Lint:** \u2705 Passed
|
|
1206
|
+
- **Test:** \u2705 Passed
|
|
1207
|
+
|
|
1208
|
+
\u{1F389} **All checks passed! Your project is in perfect shape.**`;
|
|
1209
|
+
}
|
|
1210
|
+
} else {
|
|
1211
|
+
const { success, attempts, maxAttempts, appliedFix, error, rawOutput, modelUsed, promptTokens, completionTokens } = data;
|
|
1212
|
+
if (success && appliedFix) {
|
|
1213
|
+
console.log("[BugZero] Calling AI to write solution summary report...");
|
|
1214
|
+
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 "${appliedFix.filePath}".
|
|
1215
|
+
Here is the patch details:
|
|
1216
|
+
- Root Cause: ${appliedFix.rootCause}
|
|
1217
|
+
- Explanation: ${appliedFix.explanation}
|
|
1218
|
+
- Search code:
|
|
1219
|
+
${appliedFix.search}
|
|
1220
|
+
- Replace code:
|
|
1221
|
+
${appliedFix.replace}
|
|
1222
|
+
|
|
1223
|
+
Please generate a professional, beautifully formatted Markdown report summarizing:
|
|
1224
|
+
1. **Repair Summary:** Celebrate the success and explain the fix.
|
|
1225
|
+
2. **Details of the Solution:** Walk the developer through what was changed and why.
|
|
1226
|
+
3. **Verification:** Explain how it was verified (build, lint, tests passed).
|
|
1227
|
+
|
|
1228
|
+
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1229
|
+
try {
|
|
1230
|
+
const result = await provider.invoke(prompt, { cwd });
|
|
1231
|
+
content = result.content;
|
|
1232
|
+
content += `
|
|
1233
|
+
|
|
1234
|
+
---
|
|
1235
|
+
### \u{1F916} BugZero Rescue Metadata
|
|
1236
|
+
- **AI Brain (Model) used for Fix:** \`${modelUsed || "unknown"}\`
|
|
1237
|
+
- **Token Usage for Fix:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
1238
|
+
- **AI Brain (Model) used for Report:** \`${result.model || "unknown"}\`
|
|
1239
|
+
- **Token Usage for Report:** ${result.usage ? `Prompt: **${result.usage.prompt_tokens}** | Completion: **${result.usage.completion_tokens}** | Total: **${result.usage.total_tokens}**` : "*N/A*"}`;
|
|
1240
|
+
} catch (e) {
|
|
1241
|
+
content = `# \u{1F916} BugZero Rescue Report
|
|
1242
|
+
|
|
1243
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1244
|
+
**Project Path:** \`${cwd}\`
|
|
1245
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1246
|
+
|
|
1247
|
+
## \u{1F4CA} Repair Summary
|
|
1248
|
+
- **Status:** \u2705 Fixed successfully!
|
|
1249
|
+
- **Attempts:** ${attempts} / ${maxAttempts}
|
|
1250
|
+
- **AI Brain (Model):** \`${modelUsed || "unknown"}\`
|
|
1251
|
+
- **Token Usage:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
1252
|
+
|
|
1253
|
+
## \u{1F6E0}\uFE0F Applied Solution
|
|
1254
|
+
- **Target File:** \`${appliedFix.filePath}\`
|
|
1255
|
+
- **Root Cause:** ${appliedFix.rootCause}
|
|
1256
|
+
- **Explanation:** ${appliedFix.explanation}
|
|
1257
|
+
|
|
1258
|
+
### \u{1F4DD} Code Changes
|
|
1259
|
+
**Search (Before):**
|
|
1260
|
+
\`\`\`typescript
|
|
1261
|
+
${appliedFix.search}
|
|
1262
|
+
\`\`\`
|
|
1263
|
+
|
|
1264
|
+
**Replace (After):**
|
|
1265
|
+
\`\`\`typescript
|
|
1266
|
+
${appliedFix.replace}
|
|
1267
|
+
\`\`\`
|
|
1268
|
+
`;
|
|
1269
|
+
}
|
|
1270
|
+
} else {
|
|
1271
|
+
console.log("[BugZero] Calling AI to analyze unresolved errors and write report...");
|
|
1272
|
+
const prompt = `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.
|
|
1273
|
+
Below is the unresolved error logs.
|
|
1274
|
+
Please analyze these logs and generate a professional, beautifully formatted Markdown report summarizing:
|
|
1275
|
+
1. **Analysis of Unresolved Errors:** Explain why the AI fixes might have failed or what is still unresolved.
|
|
1276
|
+
2. **Manual Action Plan:** Provide detailed, step-by-step instructions for the developer on how to fix this manually.
|
|
1277
|
+
|
|
1278
|
+
Unresolved Error Logs:
|
|
1279
|
+
${rawOutput}
|
|
1280
|
+
|
|
1281
|
+
Generate the Markdown report directly. Do not wrap it in markdown block fences (\`\`\`markdown ... \`\`\`). Just write the markdown text directly.`;
|
|
1282
|
+
try {
|
|
1283
|
+
const result = await provider.invoke(prompt, { cwd });
|
|
1284
|
+
content = result.content;
|
|
1285
|
+
content += `
|
|
1286
|
+
|
|
1287
|
+
---
|
|
1288
|
+
### \u{1F916} BugZero Rescue Metadata
|
|
1289
|
+
- **AI Brain (Model) used for Fix Attempts:** \`${modelUsed || "unknown"}\`
|
|
1290
|
+
- **Token Usage for Fix Attempts:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
1291
|
+
- **AI Brain (Model) used for Report:** \`${result.model || "unknown"}\`
|
|
1292
|
+
- **Token Usage for Report:** ${result.usage ? `Prompt: **${result.usage.prompt_tokens}** | Completion: **${result.usage.completion_tokens}** | Total: **${result.usage.total_tokens}**` : "*N/A*"}`;
|
|
1293
|
+
} catch (e) {
|
|
1294
|
+
content = `# \u{1F916} BugZero Rescue Report
|
|
1295
|
+
|
|
1296
|
+
**Date:** ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
1297
|
+
**Project Path:** \`${cwd}\`
|
|
1298
|
+
**Framework:** \`${detectFramework2(cwd)}\`
|
|
1299
|
+
|
|
1300
|
+
## \u{1F4CA} Repair Summary
|
|
1301
|
+
- **Status:** \u274C Could not repair automatically
|
|
1302
|
+
- **Attempts:** ${attempts} / ${maxAttempts}
|
|
1303
|
+
- **AI Brain (Model):** \`${modelUsed || "unknown"}\`
|
|
1304
|
+
- **Token Usage:** ${promptTokens !== void 0 && completionTokens !== void 0 ? `Prompt: **${promptTokens}** | Completion: **${completionTokens}** | Total: **${promptTokens + completionTokens}**` : "*N/A*"}
|
|
1305
|
+
|
|
1306
|
+
## \u274C Failed to Repair
|
|
1307
|
+
**Reason:** ${error || "Max attempts reached without finding a solution."}
|
|
1308
|
+
|
|
1309
|
+
### \u{1F7E5} Unresolved Errors & Logs
|
|
1310
|
+
\`\`\`text
|
|
1311
|
+
${rawOutput}
|
|
1312
|
+
\`\`\`
|
|
1313
|
+
`;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
content += `
|
|
1318
|
+
|
|
1319
|
+
---
|
|
1320
|
+
*Report generated by **BugZero** on ${(/* @__PURE__ */ new Date()).toLocaleString()}*`;
|
|
1321
|
+
const opened = await openInIDE(content);
|
|
1322
|
+
if (!opened) {
|
|
1323
|
+
console.log("\n\u26A0\uFE0F Could not automatically open the report in your IDE (no compatible editor found in PATH).");
|
|
1324
|
+
console.log("Here is the generated report:\n");
|
|
1325
|
+
console.log(content);
|
|
1326
|
+
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");
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
async function openInIDE(content) {
|
|
1330
|
+
const editors = [
|
|
1331
|
+
{ cmd: "code", args: ["-"], name: "VS Code" },
|
|
1332
|
+
{ cmd: "cursor", args: ["-"], name: "Cursor" },
|
|
1333
|
+
{ cmd: "windsurf", args: ["-"], name: "Windsurf" },
|
|
1334
|
+
{ cmd: "subl", args: ["-"], name: "Sublime Text" }
|
|
1335
|
+
];
|
|
1336
|
+
try {
|
|
1337
|
+
const { execa } = await import("execa");
|
|
1338
|
+
for (const editor of editors) {
|
|
1339
|
+
try {
|
|
1340
|
+
const proc = execa(editor.cmd, editor.args, { shell: true });
|
|
1341
|
+
if (proc.stdin) {
|
|
1342
|
+
proc.stdin.write(content);
|
|
1343
|
+
proc.stdin.end();
|
|
1344
|
+
await proc;
|
|
1345
|
+
console.log(`\u{1F5A5}\uFE0F Opened report as an unsaved tab in ${editor.name}.`);
|
|
1346
|
+
return true;
|
|
1347
|
+
}
|
|
1348
|
+
} catch (err) {
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
} catch (e) {
|
|
1352
|
+
}
|
|
1353
|
+
return false;
|
|
1082
1354
|
}
|
|
1083
1355
|
}
|
|
1084
1356
|
});
|
|
@@ -1142,6 +1414,10 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
1142
1414
|
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
1415
|
if (result.success) {
|
|
1144
1416
|
console.log(`\u2705 Build fixed after ${result.attempts} attempt(s)!`);
|
|
1417
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1418
|
+
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1419
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1420
|
+
}
|
|
1145
1421
|
if (result.appliedFix) {
|
|
1146
1422
|
console.log(` File: ${result.appliedFix.filePath}`);
|
|
1147
1423
|
console.log(` Reason: ${result.appliedFix.explanation}`);
|
|
@@ -1149,7 +1425,16 @@ program.command("rescue").description("Detect build failures and automatically a
|
|
|
1149
1425
|
}
|
|
1150
1426
|
} else {
|
|
1151
1427
|
console.log(`\u274C Could not fix build after ${result.attempts} attempt(s).`);
|
|
1428
|
+
console.log(` Model: ${result.modelUsed || "unknown"}`);
|
|
1429
|
+
if (result.promptTokens !== void 0 && result.completionTokens !== void 0) {
|
|
1430
|
+
console.log(` Tokens: Prompt: ${result.promptTokens} | Completion: ${result.completionTokens} | Total: ${result.promptTokens + result.completionTokens}`);
|
|
1431
|
+
}
|
|
1152
1432
|
if (result.error) console.log(` ${result.error}`);
|
|
1433
|
+
console.log(`
|
|
1434
|
+
\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`);
|
|
1435
|
+
console.log(result.finalOutput);
|
|
1436
|
+
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
|
|
1437
|
+
`);
|
|
1153
1438
|
}
|
|
1154
1439
|
console.log();
|
|
1155
1440
|
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
|
|