(clusters: HelperCluster[])
| 307 | |
| 308 | /** A concise, agent-readable report of extraction opportunities. PURE. */ |
| 309 | export function formatHelperClusters(clusters: HelperCluster[]): string { |
| 310 | if (!clusters.length) return 'No near-duplicate helper clusters found — nothing worth extracting.'; |
| 311 | const lines = [`Found ${clusters.length} near-duplicate helper cluster(s) — candidates to extract into a shared helper:`, '']; |
| 312 | clusters.forEach((c, i) => { |
| 313 | lines.push(`${i + 1}. ~${Math.round(c.avgSimilarity * 100)}% similar${c.exact ? ' (EXACT — use consolidate-dupes)' : ''} · ${c.members.length} copies · ~${c.estLinesSaved} lines saved → helper \`${c.suggestedName}()\``); |
| 314 | for (const m of c.members) lines.push(` - ${m.name} (${m.file}:${m.startLine}-${m.endLine})`); |
| 315 | }); |
| 316 | lines.push('', 'Detection only — extracting changes call sites. Review, then extract with a verified PR.'); |
| 317 | return lines.join('\n'); |
| 318 | } |
no test coverage detected