MCPcopy
hub / github.com/colbymchenry/codegraph / formatFilesGrouped

Method formatFilesGrouped

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

4141 * Format files grouped by language
4142 */
4143 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
4144 const byLang = new Map<string, typeof files>();
4145
4146 for (const file of files) {
4147 const existing = byLang.get(file.language) || [];
4148 existing.push(file);
4149 byLang.set(file.language, existing);
4150 }
4151
4152 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
4153
4154 // Sort languages by file count (descending)
4155 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
4156
4157 for (const [lang, langFiles] of sortedLangs) {
4158 lines.push(`**${lang} (${langFiles.length})**`);
4159 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
4160 if (includeMetadata) {
4161 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
4162 } else {
4163 lines.push(`- ${file.path}`);
4164 }
4165 }
4166 lines.push('');
4167 }
4168
4169 return lines.join('\n');
4170 }
4171
4172 /**
4173 * Format files as a tree structure

Callers 1

handleFilesMethod · 0.95

Calls 3

setMethod · 0.80
joinMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected