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

Function exploreCompletenessNotes

src/mcp/tools.ts:1398–1433  ·  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

1396 * not tell the agent to Read (AGENTS.md).
1397 */
1398export function exploreCompletenessNotes(
1399 filesIncluded: number,
1400 trimmed: ReadonlyArray<ExplorePartialFile>,
1401 /** Every path the response can name (sections and pointer list); labels are unique among them. */
1402 knownPaths: ReadonlyArray<string>,
1403): string[] {
1404 // No count when every section is held from an earlier call: "0 files" reads
1405 // as nothing shown, beside a note about what was shown.
1406 const files = filesIncluded === 0 ? 'these files'
1407 : filesIncluded === 1 ? '1 file' : `${filesIncluded} files`;
1408 if (trimmed.length === 0) {
1409 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.`];
1410 }
1411 const label = shortestUniqueSuffixes([...knownPaths, ...trimmed.map((t) => t.filePath)]);
1412 const shownFiles = trimmed.slice(0, TRIMMED_FILES_NAMED).map((t) => `\`${label.get(t.filePath)}\``);
1413 const moreFiles = trimmed.length - shownFiles.length;
1414 const trimmedList = shownFiles.join(', ') + (moreFiles > 0 ? ` +${moreFiles} more` : '');
1415 const names: string[] = [];
1416 for (const t of trimmed) {
1417 for (const e of t.elided) {
1418 if (names.length >= TRIMMED_SYMBOLS_NAMED) break;
1419 if (!(e.spine || e.importance >= 9) || TRIMMED_NAME_SKIP_KINDS.has(e.kind)) continue;
1420 const name = followUpName(e);
1421 if (!names.includes(name)) names.push(name);
1422 }
1423 }
1424 const head = `> **Verbatim source for ${files} is included above — treat it as already Read.**`;
1425 const what = 'gap markers and file headers name what was elided';
1426 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.';
1427 const withFiles = `${head} Trimmed for size: ${trimmedList}; ${what}`;
1428 const candidates = names.length > 0
1429 ? [`${withFiles} (e.g. ${names.map((n) => `\`${n}\``).join(', ')}). ${tail}`]
1430 : [];
1431 candidates.push(`${withFiles}. ${tail}`, `${head} Some sections were trimmed for size; ${what}. ${tail}`);
1432 return candidates;
1433}
1434
1435/** Chars a block of lines costs once joined into the response. */
1436const 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