MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / summarizeResultHealth

Function summarizeResultHealth

src/tools/search-codebase.ts:651–679  ·  view source on GitHub ↗
(
    resultPaths: string[]
  )

Source from the content-addressed store, hash-verified

649 }
650
651 function summarizeResultHealth(
652 resultPaths: string[]
653 ): { level: 'low' | 'medium' | 'high'; reasons?: string[] } | undefined {
654 const matched = resultPaths
655 .map((filePath) => healthByFile.get(normalizeHealthLookupKey(filePath, ctx.rootPath)))
656 .filter((entry): entry is NonNullable<typeof entry> => Boolean(entry));
657 if (matched.length === 0) {
658 return undefined;
659 }
660
661 const priority = { high: 3, medium: 2, low: 1 };
662 matched.sort((a, b) => {
663 if (priority[b.level] !== priority[a.level]) return priority[b.level] - priority[a.level];
664 if (b.score !== a.score) return b.score - a.score;
665 return a.file.localeCompare(b.file);
666 });
667
668 const top = matched[0];
669 const reasons = [...top.reasons];
670 const sameLevelCount = matched.filter((entry) => entry.level === top.level).length;
671 if (sameLevelCount > 1) {
672 reasons.push(`${sameLevelCount} result files are marked ${top.level}-risk`);
673 }
674
675 return {
676 level: top.level,
677 ...(reasons.length > 0 && { reasons: reasons.slice(0, 3) })
678 };
679 }
680
681 // Build a 1-line pattern summary string from intelligence.json patterns (compact mode)
682 function buildPatternSummary(): string | undefined {

Callers 1

handleFunction · 0.85

Calls 2

normalizeHealthLookupKeyFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected