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

Method formatFilesGrouped

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

8814 * Format files grouped by language
8815 */
8816 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
8817 const byLang = new Map<string, typeof files>();
8818
8819 for (const file of files) {
8820 const existing = byLang.get(file.language) || [];
8821 existing.push(file);
8822 byLang.set(file.language, existing);
8823 }
8824
8825 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
8826
8827 // Sort languages by file count (descending)
8828 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
8829
8830 for (const [lang, langFiles] of sortedLangs) {
8831 lines.push(`**${lang} (${langFiles.length})**`);
8832 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
8833 if (includeMetadata) {
8834 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
8835 } else {
8836 lines.push(`- ${file.path}`);
8837 }
8838 }
8839 lines.push('');
8840 }
8841
8842 return lines.join('\n');
8843 }
8844
8845 /**
8846 * 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