@@ -15,13 +15,17 @@ import { checkCrossFile } from "./checkers/cross-file.js";
1515import { checkScriptCoverage } from "./checkers/script-coverage.js" ;
1616
1717/** Run full drift detection across all scaffold files */
18- export async function runDriftCheck ( config : MexConfig ) : Promise < DriftReport > {
18+ export async function runDriftCheck (
19+ config : MexConfig ,
20+ opts : { verbose ?: boolean } = { }
21+ ) : Promise < DriftReport > {
1922 const { projectRoot, scaffoldRoot } = config ;
2023
2124 // Find all markdown files in scaffold
2225 const scaffoldFiles = findScaffoldFiles ( projectRoot , scaffoldRoot ) ;
2326 const allClaims : Claim [ ] = [ ] ;
2427 const allIssues : DriftIssue [ ] = [ ] ;
28+ const checkerIssueCounts : Array < [ string , number ] > = [ ] ;
2529
2630 // Extract claims from all files
2731 for ( const filePath of scaffoldFiles ) {
@@ -36,34 +40,55 @@ export async function runDriftCheck(config: MexConfig): Promise<DriftReport> {
3640
3741 // Frontmatter edge check
3842 const frontmatter = parseFrontmatter ( filePath ) ;
39- allIssues . push (
40- ...checkEdges ( frontmatter , filePath , source , projectRoot , scaffoldRoot )
41- ) ;
43+ const edgeIssues = checkEdges ( frontmatter , filePath , source , projectRoot , scaffoldRoot ) ;
44+ allIssues . push ( ...edgeIssues ) ;
4245
4346 // Staleness check
4447 const stalenessIssues = await checkStaleness ( source , source , projectRoot ) ;
4548 allIssues . push ( ...stalenessIssues ) ;
49+
50+ checkerIssueCounts . push ( [ `edges:${ source } ` , edgeIssues . length ] ) ;
51+ checkerIssueCounts . push ( [ `staleness:${ source } ` , stalenessIssues . length ] ) ;
4652 }
4753
4854 // Run checkers that work on claims
49- allIssues . push ( ...checkPaths ( allClaims , projectRoot , scaffoldRoot ) ) ;
50- allIssues . push ( ...checkCommands ( allClaims , projectRoot ) ) ;
51- allIssues . push ( ...checkDependencies ( allClaims , projectRoot ) ) ;
52- allIssues . push ( ...checkCrossFile ( allClaims ) ) ;
55+ const pathIssues = checkPaths ( allClaims , projectRoot , scaffoldRoot ) ;
56+ allIssues . push ( ...pathIssues ) ;
57+ checkerIssueCounts . push ( [ "paths" , pathIssues . length ] ) ;
58+
59+ const commandIssues = checkCommands ( allClaims , projectRoot ) ;
60+ allIssues . push ( ...commandIssues ) ;
61+ checkerIssueCounts . push ( [ "commands" , commandIssues . length ] ) ;
62+
63+ const dependencyIssues = checkDependencies ( allClaims , projectRoot ) ;
64+ allIssues . push ( ...dependencyIssues ) ;
65+ checkerIssueCounts . push ( [ "dependencies" , dependencyIssues . length ] ) ;
66+
67+ const crossFileIssues = checkCrossFile ( allClaims ) ;
68+ allIssues . push ( ...crossFileIssues ) ;
69+ checkerIssueCounts . push ( [ "cross-file" , crossFileIssues . length ] ) ;
5370
5471 // Run structural checkers
55- allIssues . push ( ...checkIndexSync ( projectRoot , scaffoldRoot ) ) ;
72+ const indexSyncIssues = checkIndexSync ( projectRoot , scaffoldRoot ) ;
73+ allIssues . push ( ...indexSyncIssues ) ;
74+ checkerIssueCounts . push ( [ "index-sync" , indexSyncIssues . length ] ) ;
5675
5776 // Run coverage checkers (reality → scaffold direction)
58- allIssues . push ( ...checkScriptCoverage ( scaffoldFiles , projectRoot ) ) ;
77+ const scriptCoverageIssues = checkScriptCoverage ( scaffoldFiles , projectRoot ) ;
78+ allIssues . push ( ...scriptCoverageIssues ) ;
79+ checkerIssueCounts . push ( [ "script-coverage" , scriptCoverageIssues . length ] ) ;
5980
6081 const score = computeScore ( allIssues ) ;
82+ const verboseLog = opts . verbose
83+ ? buildVerboseLog ( scaffoldFiles . length , allClaims , checkerIssueCounts )
84+ : undefined ;
6185
6286 return {
6387 score,
6488 issues : allIssues ,
6589 filesChecked : scaffoldFiles . length ,
6690 timestamp : new Date ( ) . toISOString ( ) ,
91+ verboseLog,
6792 } ;
6893}
6994
@@ -108,3 +133,21 @@ function findScaffoldFiles(
108133 // Deduplicate
109134 return [ ...new Set ( files ) ] ;
110135}
136+
137+ export function buildVerboseLog (
138+ filesScanned : number ,
139+ claims : Claim [ ] ,
140+ checkerIssueCounts : Array < [ string , number ] >
141+ ) : string [ ] {
142+ const pathClaims = claims . filter ( ( claim ) => claim . kind === "path" ) . length ;
143+ const commandClaims = claims . filter ( ( claim ) => claim . kind === "command" ) . length ;
144+ const dependencyClaims = claims . filter ( ( claim ) => claim . kind === "dependency" ) . length ;
145+
146+ return [
147+ `Scaffold files scanned: ${ filesScanned } ` ,
148+ `Claims extracted: ${ claims . length } (path: ${ pathClaims } , command: ${ commandClaims } , dependency: ${ dependencyClaims } )` ,
149+ ...checkerIssueCounts . map (
150+ ( [ checker , count ] ) => `Checker ${ checker } : ${ count } issue${ count === 1 ? "" : "s" } `
151+ ) ,
152+ ] ;
153+ }
0 commit comments