UNPKG

scai

Version:

> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.

49 lines (37 loc) 1.53 kB
"use strict"; /* import { PromptModule, PromptInput, PromptOutput } from "../../types.js"; import { generate } from "../../lib/generate.js"; import { Config } from "../../config.js"; export const repairTestsModule: PromptModule = { name: "repairTestsModule", description: "Fix failing Jest tests using AI", async run({ content, filepath, summary }: PromptInput): Promise<PromptOutput> { const model = Config.getModel(); const prompt = ` You are a senior engineer tasked with repairing Jest tests. The following test file failed: --- BEGIN TEST FILE --- ${content} --- END TEST FILE --- Failure summary: ${summary || "No summary provided."} Instructions: - Keep the overall structure, imports, and test cases. - Only fix syntax errors, invalid Jest matchers, or broken references. - Do NOT remove or replace entire test suites unless strictly necessary. - Do NOT generate trivial placeholder tests (like add(2,3) examples). - Only return valid Jest code, no explanations, no markdown fences. Output the repaired test file: `.trim(); const response = await generate({ content: prompt }); if (!response) throw new Error("⚠️ No repaired test code returned from model"); return { originalContent: content, content: response.content, // repaired test code filepath, // repair in-place summary: `Repaired tests based on failure: ${summary || "unknown error"}`, mode: "overwrite" // signal to overwrite existing test file }; } }; */