Test cases: - [x] create-ts-errors - [x] with auto-fix - [x] without auto-fix - [x] create-unfixable-ts-errors - [x] manually edit file & click recheck - [x] fix all - [x] delete and rename case THINGS - [x] error handling for checkProblems isn't working as expected - [x] make sure it works for both default templates (add tests) - [x] fix bad animation - [x] change file context (prompt/files) IF everything passes in Windows AND defensive try catch... then enable by default - [x] enable auto-fix by default
25 lines
770 B
TypeScript
25 lines
770 B
TypeScript
import type { ProblemReport } from "../ipc/ipc_types";
|
|
|
|
/**
|
|
* Creates a more concise version of the problem fix prompt for cases where
|
|
* brevity is preferred.
|
|
*/
|
|
export function createProblemFixPrompt(problemReport: ProblemReport): string {
|
|
const { problems } = problemReport;
|
|
|
|
if (problems.length === 0) {
|
|
return "No TypeScript problems detected.";
|
|
}
|
|
|
|
const totalProblems = problems.length;
|
|
let prompt = `Fix these ${totalProblems} TypeScript compile-time error${totalProblems === 1 ? "" : "s"}:\n\n`;
|
|
|
|
problems.forEach((problem, index) => {
|
|
prompt += `${index + 1}. ${problem.file}:${problem.line}:${problem.column} - ${problem.message} (TS${problem.code})\n`;
|
|
});
|
|
|
|
prompt += "\nPlease fix all errors in a concise way.";
|
|
|
|
return prompt;
|
|
}
|