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

Method formatFilesGrouped

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

9236 * Format files grouped by language
9237 */
9238 private formatFilesGrouped(files: { path: string; language: string; nodeCount: number }[], includeMetadata: boolean): string {
9239 const byLang = new Map<string, typeof files>();
9240
9241 for (const file of files) {
9242 const existing = byLang.get(file.language) || [];
9243 existing.push(file);
9244 byLang.set(file.language, existing);
9245 }
9246
9247 const lines: string[] = [`**Files by Language (${files.length} total)**`, ''];
9248
9249 // Sort languages by file count (descending)
9250 const sortedLangs = [...byLang.entries()].sort((a, b) => b[1].length - a[1].length);
9251
9252 for (const [lang, langFiles] of sortedLangs) {
9253 lines.push(`**${lang} (${langFiles.length})**`);
9254 for (const file of langFiles.sort((a, b) => a.path.localeCompare(b.path))) {
9255 if (includeMetadata) {
9256 lines.push(`- ${file.path} (${file.nodeCount} symbols)`);
9257 } else {
9258 lines.push(`- ${file.path}`);
9259 }
9260 }
9261 lines.push('');
9262 }
9263
9264 return lines.join('\n');
9265 }
9266
9267 /**
9268 * 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