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

Function readIndexedFileText

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

Source from the content-addressed store, hash-verified

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

Callers 2

buildDeadCodeFunction · 0.90
withoutPreviewsFunction · 0.90

Calls 2

resolveProjectFileFunction · 0.90
findIndexedFileFunction · 0.85

Tested by

no test coverage detected