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

Method formatFilesGrouped

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

4270 * Format files grouped by language
4271 */
4272 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
4273 const byLang = new Map<string, typeof files>();
4274
4275 for (const file of files) {
4276 const existing = byLang.get(file.language) || [];
4277 existing.push(file);
4278 byLang.set(file.language, existing);
4279 }
4280
4281 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
4282
4283 // Sort languages by file count (descending)
4284 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
4285
4286 for (const [lang, langFiles] of sortedLangs) {
4287 lines.push(`**${lang} (${langFiles.length})**`);
4288 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
4289 if (includeMetadata) {
4290 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
4291 } else {
4292 lines.push(`- ${file.path}`);
4293 }
4294 }
4295 lines.push('');
4296 }
4297
4298 return lines.join('\n');
4299 }
4300
4301 /**
4302 * 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