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

Function readIndexedFileText

src/ui-server/api/source.ts:170–186  ·  view source on GitHub ↗
(
  cg: CodeGraph,
  projectRoot: string,
  requested: string,
  maxBytes: number
)

Source from the content-addressed store, hash-verified

168 * answer to it than the bytes we indexed.
169 */
170export function readIndexedFileText(
171 cg: CodeGraph,
172 projectRoot: string,
173 requested: string,
174 maxBytes: number
175): string | null {
176 try {
177 const found = findIndexedFile(cg, requested);
178 if (!found) return null;
179 const absolute = resolveProjectFile(projectRoot, found.storedPath);
180 const stats = fs.statSync(absolute);
181 if (!stats.isFile() || stats.size > maxBytes) return null;
182 return fs.readFileSync(absolute, 'utf8');
183 } catch {
184 return null;
185 }
186}
187
188/**
189 * Whether an indexed file has changed on disk since it was indexed — the same

Callers 1

buildDeadCodeFunction · 0.90

Calls 2

resolveProjectFileFunction · 0.90
findIndexedFileFunction · 0.85

Tested by

no test coverage detected