MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / fileCycles

Function fileCycles

src/ui-server/api/map.ts:813–832  ·  view source on GitHub ↗

* The circular imports inside the chosen root (see findFileCycles). * * A component longer than MAX_CYCLE_LENGTH is reported truncated rather * than printed — a 200-file knot is a fact about the repository, not a list * anybody reads.

(
  pairs: ReadonlyArray<{ source: string; target: string }>,
  moduleOfFile: Map<string, string>
)

Source from the content-addressed store, hash-verified

811 * anybody reads.
812 */
813function fileCycles(
814 pairs: ReadonlyArray<{ source: string; target: string }>,
815 moduleOfFile: Map<string, string>
816): WireMapPayload['cycles'] {
817 const cycles = findFileCycles(
818 pairs.filter((pair) => moduleOfFile.has(pair.source) && moduleOfFile.has(pair.target))
819 );
820
821 const items = cycles.slice(0, MAX_FILE_CYCLES).map((files) => ({
822 size: files.length,
823 files: files.slice(0, MAX_CYCLE_LENGTH),
824 modules: [...new Set(files.map((file) => moduleOfFile.get(file) ?? file))].sort(),
825 }));
826 return {
827 total: cycles.length,
828 shown: items.length,
829 truncated: cycles.length > items.length,
830 items,
831 };
832}
833
834/**
835 * The roots the selector offers: the repository root plus every top-level

Callers 1

buildMapFunction · 0.85

Calls 4

findFileCyclesFunction · 0.90
hasMethod · 0.80
mapMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected