@@ -13,6 +13,8 @@ interface GrepInput {
1313 glob ?: string ;
1414 output_mode ?: 'content' | 'files_with_matches' | 'count' ;
1515 context ?: number ;
16+ before_context ?: number ;
17+ after_context ?: number ;
1618 case_insensitive ?: boolean ;
1719 head_limit ?: number ;
1820 multiline ?: boolean ;
@@ -73,6 +75,9 @@ function runRipgrep(
7375 args . push ( '-n' ) ;
7476 if ( opts . context && opts . context > 0 ) {
7577 args . push ( `-C${ opts . context } ` ) ;
78+ } else {
79+ if ( opts . before_context && opts . before_context > 0 ) args . push ( `-B${ opts . before_context } ` ) ;
80+ if ( opts . after_context && opts . after_context > 0 ) args . push ( `-A${ opts . after_context } ` ) ;
7681 }
7782 break ;
7883 }
@@ -183,6 +188,8 @@ export const grepCapability: CapabilityHandler = {
183188 description : 'Output mode: "content" (matching lines), "files_with_matches" (file paths), "count" (match counts). Default: files_with_matches' ,
184189 } ,
185190 context : { type : 'number' , description : 'Lines of context around each match (content mode only)' } ,
191+ before_context : { type : 'number' , description : 'Lines before each match (-B, content mode)' } ,
192+ after_context : { type : 'number' , description : 'Lines after each match (-A, content mode)' } ,
186193 case_insensitive : { type : 'boolean' , description : 'Case-insensitive search' } ,
187194 head_limit : { type : 'number' , description : 'Max results to return. Default: 250' } ,
188195 multiline : { type : 'boolean' , description : 'Enable multiline mode (patterns span lines). Default: false' } ,
0 commit comments