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

Method boundFiles

src/mcp/explore-session-state.ts:312–327  ·  view source on GitHub ↗

* Normalize + bound one call's files: coalesce each file's ranges, then keep * the files that got the most source. A call that renders more files than the * bound has already spread its envelope thin, so the tail files carry the * least — and losing them costs the least.

(files: ReadonlyArray<ExploreFileEmission> | undefined)

Source from the content-addressed store, hash-verified

310 * least — and losing them costs the least.
311 */
312 private boundFiles(files: ReadonlyArray<ExploreFileEmission> | undefined): ExploreFileEmission[] {
313 if (!Array.isArray(files) || files.length === 0) return [];
314 const normalized = files
315 .filter((f) => f && typeof f.path === 'string' && f.path.length > 0)
316 .map((f) => {
317 const { ranges, truncated } = coalesceRanges(f.ranges ?? []);
318 const out: ExploreFileEmission = { path: f.path, ranges, bytes: Math.max(0, f.bytes || 0) };
319 if (typeof f.fingerprint === 'string' && f.fingerprint) out.fingerprint = f.fingerprint;
320 if (truncated) out.rangesTruncated = true;
321 return out;
322 });
323 if (normalized.length <= EXPLORE_SESSION_LIMITS.MAX_FILES_PER_CALL) return normalized;
324 return [...normalized]
325 .sort((a, b) => b.bytes - a.bytes)
326 .slice(0, EXPLORE_SESSION_LIMITS.MAX_FILES_PER_CALL);
327 }
328}
329
330function cloneProject(state: MutableProjectState): ExploreProjectState {

Callers 1

recordMethod · 0.95

Calls 2

coalesceRangesFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected