MCPcopy Create free account
hub / github.com/anus-dev/ANUS / ensureCorrectFileContent

Function ensureCorrectFileContent

packages/core/src/utils/editCorrector.ts:336–360  ·  view source on GitHub ↗
(
  content: string,
  client: AnusClient,
  abortSignal: AbortSignal,
)

Source from the content-addressed store, hash-verified

334}
335
336export 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
363const OLD_STRING_CORRECTION_SCHEMA: Record<string, unknown> = {

Callers 2

getCorrectedFileContentFunction · 0.85

Calls 4

unescapeStringForAnusBugFunction · 0.85
correctStringEscapingFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected