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

Method formatFilesGrouped

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

9273 * Format files grouped by language
9274 */
9275 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
9276 const byLang = new Map<string, typeof files>();
9277
9278 for (const file of files) {
9279 const existing = byLang.get(file.language) || [];
9280 existing.push(file);
9281 byLang.set(file.language, existing);
9282 }
9283
9284 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
9285
9286 // Sort languages by file count (descending)
9287 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
9288
9289 for (const [lang, langFiles] of sortedLangs) {
9290 lines.push(`**${lang} (${langFiles.length})**`);
9291 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
9292 if (includeMetadata) {
9293 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
9294 } else {
9295 lines.push(`- ${file.path}`);
9296 }
9297 }
9298 lines.push('');
9299 }
9300
9301 return lines.join('\n');
9302 }
9303
9304 /**
9305 * 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