@@ -93,8 +93,10 @@ export async function generateFoldedFileContext(
9393
9494 const foldedSections : string [ ] = [ ]
9595 let currentCharCount = 0
96+ const failedFiles : string [ ] = [ ]
9697
97- for ( const filePath of filePaths ) {
98+ for ( let i = 0 ; i < filePaths . length ; i ++ ) {
99+ const filePath = filePaths [ i ]
98100 // Resolve to absolute path for tree-sitter
99101 const absolutePath = path . isAbsolute ( filePath ) ? filePath : path . resolve ( cwd , filePath )
100102
@@ -119,9 +121,9 @@ ${definitions}
119121 // Would exceed limit - check if we can fit at least a truncated version
120122 const remainingChars = maxCharacters - currentCharCount
121123 if ( remainingChars < 200 ) {
122- // Not enough room for meaningful content, stop processing
123- result . filesSkipped ++
124- continue
124+ // Not enough room for meaningful content, stop processing all remaining files
125+ result . filesSkipped += filePaths . length - i
126+ break
125127 }
126128
127129 // Truncate the definitions to fit within the system-reminder block
@@ -143,11 +145,19 @@ ${truncatedDefinitions}
143145 currentCharCount += sectionContent . length
144146 result . filesProcessed ++
145147 } catch ( error ) {
146- console . error ( `Failed to generate folded context for ${ filePath } :` , error )
148+ // Collect failed files for batch logging to reduce noise
149+ failedFiles . push ( filePath )
147150 result . filesSkipped ++
148151 }
149152 }
150153
154+ // Log failed files as a single batch summary instead of per-file errors
155+ if ( failedFiles . length > 0 ) {
156+ console . warn (
157+ `Folded context generation: skipped ${ failedFiles . length } file(s) due to errors: ${ failedFiles . slice ( 0 , 5 ) . join ( ", " ) } ${ failedFiles . length > 5 ? ` and ${ failedFiles . length - 5 } more` : "" } ` ,
158+ )
159+ }
160+
151161 if ( foldedSections . length > 0 ) {
152162 result . sections = foldedSections
153163 result . content = foldedSections . join ( "\n" )
0 commit comments