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

Function exploreCompletenessNotes

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

1513 * not tell the agent to Read (AGENTS.md).
1514 */
1515export function exploreCompletenessNotes(
1516 filesIncluded: number,
1517 trimmed: ReadonlyArray<ExplorePartialFile>,
1518 /** Every path the response can name (sections and pointer list); labels are unique among them. */
1519 knownPaths: ReadonlyArray<string>,
1520): string[] {
1521 // No count when every section is held from an earlier call: "0 files" reads
1522 // as nothing shown, beside a note about what was shown.
1523 const files = filesIncluded === 0 ? 'these files'
1524 : filesIncluded === 1 ? '1 file' : `${filesIncluded} files`;
1525 if (trimmed.length === 0) {
1526 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.`];
1527 }
1528 const label = shortestUniqueSuffixes([...knownPaths, ...trimmed.map((t) => t.filePath)]);
1529 const shownFiles = trimmed.slice(0, TRIMMED_FILES_NAMED).map((t) => `\`${label.get(t.filePath)}\``);
1530 const moreFiles = trimmed.length - shownFiles.length;
1531 const trimmedList = shownFiles.join(', ') + (moreFiles > 0 ? ` +${moreFiles} more` : '');
1532 const names: string[] = [];
1533 for (const t of trimmed) {
1534 for (const e of t.elided) {
1535 if (names.length >= TRIMMED_SYMBOLS_NAMED) break;
1536 if (!(e.spine || e.importance >= 9) || TRIMMED_NAME_SKIP_KINDS.has(e.kind)) continue;
1537 const name = followUpName(e);
1538 if (!names.includes(name)) names.push(name);
1539 }
1540 }
1541 const head = `> **Verbatim source for ${files} is included above — treat it as already Read.**`;
1542 const what = 'gap markers and file headers name what was elided';
1543 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.';
1544 const withFiles = `${head} Trimmed for size: ${trimmedList}; ${what}`;
1545 const candidates = names.length > 0
1546 ? [`${withFiles} (e.g. ${names.map((n) => `\`${n}\``).join(', ')}). ${tail}`]
1547 : [];
1548 candidates.push(`${withFiles}. ${tail}`, `${head} Some sections were trimmed for size; ${what}. ${tail}`);
1549 return candidates;
1550}
1551
1552/** Chars a block of lines costs once joined into the response. */
1553const 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