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

Method formatFilesGrouped

src/mcp/tools.ts:6600–6627  ·  view source on GitHub ↗

* Format files grouped by language

(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean)

Source from the content-addressed store, hash-verified

6598 * Format files grouped by language
6599 */
6600 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
6601 const byLang = new Map<string, typeof files>();
6602
6603 for (const file of files) {
6604 const existing = byLang.get(file.language) || [];
6605 existing.push(file);
6606 byLang.set(file.language, existing);
6607 }
6608
6609 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
6610
6611 // Sort languages by file count (descending)
6612 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
6613
6614 for (const [lang, langFiles] of sortedLangs) {
6615 lines.push(`**${lang} (${langFiles.length})**`);
6616 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
6617 if (includeMetadata) {
6618 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
6619 } else {
6620 lines.push(`- ${file.path}`);
6621 }
6622 }
6623 lines.push('');
6624 }
6625
6626 return lines.join('\n');
6627 }
6628
6629 /**
6630 * Format files as a tree structure

Callers 1

handleFilesMethod · 0.95

Calls 3

getMethod · 0.65
setMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected