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

Method formatFilesGrouped

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

8961 * Format files grouped by language
8962 */
8963 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
8964 const byLang = new Map<string, typeof files>();
8965
8966 for (const file of files) {
8967 const existing = byLang.get(file.language) || [];
8968 existing.push(file);
8969 byLang.set(file.language, existing);
8970 }
8971
8972 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
8973
8974 // Sort languages by file count (descending)
8975 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
8976
8977 for (const [lang, langFiles] of sortedLangs) {
8978 lines.push(`**${lang} (${langFiles.length})**`);
8979 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
8980 if (includeMetadata) {
8981 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
8982 } else {
8983 lines.push(`- ${file.path}`);
8984 }
8985 }
8986 lines.push('');
8987 }
8988
8989 return lines.join('\n');
8990 }
8991
8992 /**
8993 * 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