@@ -382,17 +382,62 @@ export function handleGetTechnicalDebt(args: any) {
382382 . map ( line => {
383383 const match = line . trim ( ) . match ( / ^ \s * ( \d + ) \s + ( .+ ) $ / ) ;
384384 if ( match ) {
385- return { file : match [ 2 ] , churn : parseInt ( match [ 1 ] ) } ;
385+ return { file : match [ 2 ] , changes : parseInt ( match [ 1 ] ) } ;
386386 }
387387 return null ;
388388 } )
389389 . filter ( x => x !== null )
390390 . slice ( 0 , 10 ) ;
391391 } catch { }
392392
393+ // Get large files (>500 lines)
394+ let largeFiles : any [ ] = [ ] ;
395+ try {
396+ const filesCmd = `git ls-files` ;
397+ const files = runGitCommand ( repo_path , filesCmd ) . trim ( ) . split ( "\n" ) . filter ( f => f ) ;
398+
399+ for ( const file of files . slice ( 0 , 100 ) ) {
400+ try {
401+ const linesCmd = `wc -l "${ file } "` ;
402+ const output = runGitCommand ( repo_path , linesCmd ) . trim ( ) ;
403+ const lines = parseInt ( output . split ( / \s + / ) [ 0 ] ) ;
404+ if ( lines > 500 ) {
405+ largeFiles . push ( { file, lines } ) ;
406+ }
407+ } catch { }
408+ }
409+ largeFiles = largeFiles . sort ( ( a , b ) => b . lines - a . lines ) . slice ( 0 , 10 ) ;
410+ } catch { }
411+
412+ // Calculate average file age
413+ let averageFileAge = null ;
414+ try {
415+ const filesCmd = `git ls-files` ;
416+ const files = runGitCommand ( repo_path , filesCmd ) . trim ( ) . split ( "\n" ) . filter ( f => f ) ;
417+ const now = Math . floor ( Date . now ( ) / 1000 ) ;
418+ let totalAge = 0 ;
419+ let count = 0 ;
420+
421+ for ( const file of files . slice ( 0 , 100 ) ) {
422+ try {
423+ const lastChangeCmd = `git log -1 --format=%ct -- "${ file } "` ;
424+ const timestamp = parseInt ( runGitCommand ( repo_path , lastChangeCmd ) . trim ( ) ) ;
425+ const days = Math . floor ( ( now - timestamp ) / 86400 ) ;
426+ totalAge += days ;
427+ count ++ ;
428+ } catch { }
429+ }
430+
431+ if ( count > 0 ) {
432+ averageFileAge = Math . round ( totalAge / count ) ;
433+ }
434+ } catch { }
435+
393436 return {
394437 staleFiles,
438+ largeFiles,
395439 complexityHotspots,
440+ averageFileAge,
396441 } ;
397442}
398443
0 commit comments