autoheal
Version:
GPT Test driven development. Automatically fix tests and guide GPT to write and fix code using your tests.
49 lines (48 loc) • 2.34 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { prompt } from "./prompt.js";
export function determineFilesToFix(testDetails) {
return __awaiter(this, void 0, void 0, function* () {
const possibleFilesToFix = [
"./src/Customer.ts",
"./src/Order.ts",
"./src/Product.ts",
"./src/OrderLineItem.ts",
];
// await wait(1000);
// return possibleFilesToFix;
const response = yield prompt([
{
role: "system",
content: "You are simple program that looks at the test results and return the files to fix in a comma separated list. You are not a conversational agent.",
},
{
role: "user",
content: "You will be given results of a test run and a list of files," +
" and reply with the files that are likely to be causing " +
" the test failures. You will only return a list of files and not provide any additional context.",
},
{
role: "assistant",
content: "Yes, understood. I will only reply with a list of files and not provide any context",
},
{
role: "user",
content: "List of possible files:\n" +
possibleFilesToFix.map((f) => "- " + f).join("\n") +
"Test run results:\n```" +
testDetails +
"\n```\n",
},
]);
const filesToFix = (response === null || response === void 0 ? void 0 : response.split(", ")) || [];
return [...filesToFix];
});
}