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

Method formatFilesGrouped

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

4507 * Format files grouped by language
4508 */
4509 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
4510 const byLang = new Map<string, typeof files>();
4511
4512 for (const file of files) {
4513 const existing = byLang.get(file.language) || [];
4514 existing.push(file);
4515 byLang.set(file.language, existing);
4516 }
4517
4518 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
4519
4520 // Sort languages by file count (descending)
4521 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
4522
4523 for (const [lang, langFiles] of sortedLangs) {
4524 lines.push(`**${lang} (${langFiles.length})**`);
4525 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
4526 if (includeMetadata) {
4527 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
4528 } else {
4529 lines.push(`- ${file.path}`);
4530 }
4531 }
4532 lines.push('');
4533 }
4534
4535 return lines.join('\n');
4536 }
4537
4538 /**
4539 * 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