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

Method readFile

src/mcp/tools.ts:8152–8167  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

8150 // a changed file's indexed line numbers can point at other code (#1474).
8151 const read = new Map<string, { content: string; lines: string[] } | null>();
8152 const readFile = (filePath: string) => {
8153 const held = read.get(filePath);
8154 if (held !== undefined) return held;
8155 let entry: { content: string; lines: string[] } | null = null;
8156 try {
8157 const abs = validatePathWithinRoot(projectRoot, filePath);
8158 if (abs && existsSync(abs)) {
8159 const content = readFileSync(abs, 'utf-8');
8160 if (!this.isFileStaleOnDisk(cg, filePath, content)) entry = { content, lines: content.split(/\r?\n/) };
8161 }
8162 } catch {
8163 entry = null;
8164 }
8165 read.set(filePath, entry);
8166 return entry;
8167 };
8168
8169 const isTest = this.testCodeReading(cg);
8170 const rel = (p: string) => p.replace(/\\/g, '/');

Callers

nothing calls this directly

Calls 4

isFileStaleOnDiskMethod · 0.95
validatePathWithinRootFunction · 0.90
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected