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

Method formatFilesGrouped

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

8987 * Format files grouped by language
8988 */
8989 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
8990 const byLang = new Map<string, typeof files>();
8991
8992 for (const file of files) {
8993 const existing = byLang.get(file.language) || [];
8994 existing.push(file);
8995 byLang.set(file.language, existing);
8996 }
8997
8998 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
8999
9000 // Sort languages by file count (descending)
9001 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
9002
9003 for (const [lang, langFiles] of sortedLangs) {
9004 lines.push(`**${lang} (${langFiles.length})**`);
9005 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
9006 if (includeMetadata) {
9007 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
9008 } else {
9009 lines.push(`- ${file.path}`);
9010 }
9011 }
9012 lines.push('');
9013 }
9014
9015 return lines.join('\n');
9016 }
9017
9018 /**
9019 * Format files grouped by the package that owns them

Callers 1

handleFilesMethod · 0.95

Calls 4

pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected