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

Function exploreCompletenessNotes

src/mcp/tools.ts:1392–1427  ·  view source on GitHub ↗
(
  filesIncluded: number,
  trimmed: ReadonlyArray<ExplorePartialFile>,
  /** Every path the response can name (sections and pointer list); labels are unique among them. */
  knownPaths: ReadonlyArray<string>,
)

Source from the content-addressed store, hash-verified

1390 * not tell the agent to Read (AGENTS.md).
1391 */
1392export function exploreCompletenessNotes(
1393 filesIncluded: number,
1394 trimmed: ReadonlyArray<ExplorePartialFile>,
1395 /** Every path the response can name (sections and pointer list); labels are unique among them. */
1396 knownPaths: ReadonlyArray<string>,
1397): string[] {
1398 // No count when every section is held from an earlier call: "0 files" reads
1399 // as nothing shown, beside a note about what was shown.
1400 const files = filesIncluded === 0 ? 'these files'
1401 : filesIncluded === 1 ? '1 file' : `${filesIncluded} files`;
1402 if (trimmed.length === 0) {
1403 return [`> **Complete source for ${files} is included above — do NOT re-read them.** If your question also needs files/symbols listed under "Not shown above" (or any area this call didn't cover), make ANOTHER codegraph_explore targeting those names — it returns the same source with line numbers and is cheaper and more complete than reading.`];
1404 }
1405 const label = shortestUniqueSuffixes([...knownPaths, ...trimmed.map((t) => t.filePath)]);
1406 const shownFiles = trimmed.slice(0, TRIMMED_FILES_NAMED).map((t) => `\`${label.get(t.filePath)}\``);
1407 const moreFiles = trimmed.length - shownFiles.length;
1408 const trimmedList = shownFiles.join(', ') + (moreFiles > 0 ? ` +${moreFiles} more` : '');
1409 const names: string[] = [];
1410 for (const t of trimmed) {
1411 for (const e of t.elided) {
1412 if (names.length >= TRIMMED_SYMBOLS_NAMED) break;
1413 if (!(e.spine || e.importance >= 9) || TRIMMED_NAME_SKIP_KINDS.has(e.kind)) continue;
1414 const name = followUpName(e);
1415 if (!names.includes(name)) names.push(name);
1416 }
1417 }
1418 const head = `> **Verbatim source for ${files} is included above — treat it as already Read.**`;
1419 const what = 'gap markers and file headers name what was elided';
1420 const tail = 'For those, or anything under "Not shown above", make ANOTHER codegraph_explore with those exact names instead of reading the files — it returns their source with line numbers.';
1421 const withFiles = `${head} Trimmed for size: ${trimmedList}; ${what}`;
1422 const candidates = names.length > 0
1423 ? [`${withFiles} (e.g. ${names.map((n) => `\`${n}\``).join(', ')}). ${tail}`]
1424 : [];
1425 candidates.push(`${withFiles}. ${tail}`, `${head} Some sections were trimmed for size; ${what}. ${tail}`);
1426 return candidates;
1427}
1428
1429/** Chars a block of lines costs once joined into the response. */
1430const roomForLines = (block: readonly string[]): number =>

Callers 2

handleExploreMethod · 0.85

Calls 7

shortestUniqueSuffixesFunction · 0.85
followUpNameFunction · 0.85
mapMethod · 0.80
hasMethod · 0.80
pushMethod · 0.80
getMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected