( content: string, client: AnusClient, abortSignal: AbortSignal, )
| 334 | } |
| 335 | |
| 336 | export async function ensureCorrectFileContent( |
| 337 | content: string, |
| 338 | client: AnusClient, |
| 339 | abortSignal: AbortSignal, |
| 340 | ): Promise<string> { |
| 341 | const cachedResult = fileContentCorrectionCache.get(content); |
| 342 | if (cachedResult) { |
| 343 | return cachedResult; |
| 344 | } |
| 345 | |
| 346 | const contentPotentiallyEscaped = |
| 347 | unescapeStringForAnusBug(content) !== content; |
| 348 | if (!contentPotentiallyEscaped) { |
| 349 | fileContentCorrectionCache.set(content, content); |
| 350 | return content; |
| 351 | } |
| 352 | |
| 353 | const correctedContent = await correctStringEscaping( |
| 354 | content, |
| 355 | client, |
| 356 | abortSignal, |
| 357 | ); |
| 358 | fileContentCorrectionCache.set(content, correctedContent); |
| 359 | return correctedContent; |
| 360 | } |
| 361 | |
| 362 | // Define the expected JSON schema for the LLM response for old_string correction |
| 363 | const OLD_STRING_CORRECTION_SCHEMA: Record<string, unknown> = { |
no test coverage detected