11use std:: { env, io:: BufWriter , path:: PathBuf , sync:: mpsc, time:: Instant } ;
22
3- use oxc_diagnostics:: { DiagnosticService , reporter :: DiagnosticReporter } ;
3+ use oxc_diagnostics:: DiagnosticService ;
44
55use super :: {
66 command:: { FormatCommand , Mode , OutputMode } ,
7- reporter:: { AgentReporter , DefaultReporter } ,
7+ reporter:: DefaultReporter ,
88 resolve:: resolve_ignore_paths,
99 result:: CliRunResult ,
1010 service:: { FormatService , SuccessResult } ,
@@ -69,20 +69,13 @@ impl WalkRunner {
6969 let start_time = Instant :: now ( ) ;
7070
7171 let cwd = self . cwd ;
72- let FormatCommand {
73- paths,
74- mode,
75- output_options,
76- config_options,
77- ignore_options,
78- runtime_options,
79- } = self . options ;
72+ let FormatCommand { paths, mode, config_options, ignore_options, runtime_options } =
73+ self . options ;
8074 // If `napi` feature is disabled, there is no other mode.
8175 #[ cfg_attr( not( feature = "napi" ) , expect( irrefutable_let_patterns) ) ]
8276 let Mode :: Cli ( format_mode) = mode else {
8377 unreachable ! ( "`WalkRunner` should only be called with Mode::Cli" ) ;
8478 } ;
85- let agent_output = output_options. agent ;
8679 let num_of_threads = rayon:: current_num_threads ( ) ;
8780
8881 // Find and load root config file
@@ -147,14 +140,10 @@ impl WalkRunner {
147140 // Collect format results (changed paths or unchanged count)
148141 let ( tx_success, rx_success) = mpsc:: channel ( ) ;
149142 // Diagnostic from formatting service
150- let reporter: Box < dyn DiagnosticReporter > = if agent_output {
151- Box :: new ( AgentReporter )
152- } else {
153- Box :: new ( DefaultReporter :: default ( ) )
154- } ;
155- let ( mut diagnostic_service, tx_error) = DiagnosticService :: new ( reporter) ;
143+ let ( mut diagnostic_service, tx_error) =
144+ DiagnosticService :: new ( Box :: new ( DefaultReporter :: default ( ) ) ) ;
156145
157- if matches ! ( format_mode, OutputMode :: Check ) && !agent_output {
146+ if matches ! ( format_mode, OutputMode :: Check ) {
158147 utils:: print_and_flush ( stdout, "Checking formatting...\n " ) ;
159148 utils:: print_and_flush ( stdout, "\n " ) ;
160149 }
@@ -172,8 +161,7 @@ impl WalkRunner {
172161 // Spawn formatting service on a dedicated thread so it doesn't occupy the rayon pool.
173162 // It just blocks on `rx_entry` waiting for entries; `par_bridge()` inside still uses rayon.
174163 std:: thread:: spawn ( move || {
175- let format_service =
176- FormatService :: new ( cwd, format_mode, source_formatter, agent_output) ;
164+ let format_service = FormatService :: new ( cwd, format_mode, source_formatter) ;
177165 format_service. run_streaming ( rx_entry, & tx_error_for_format, & tx_success) ;
178166 } ) ;
179167
@@ -218,11 +206,7 @@ impl WalkRunner {
218206 // Print sorted changed file paths to stdout
219207 if !changed_paths. is_empty ( ) {
220208 changed_paths. sort_unstable ( ) ;
221- if agent_output {
222- utils:: print_and_flush ( stdout, & format ! ( "{}\n " , changed_paths. join( "\n " ) ) ) ;
223- } else {
224- utils:: print_and_flush ( stdout, & changed_paths. join ( "\n " ) ) ;
225- }
209+ utils:: print_and_flush ( stdout, & changed_paths. join ( "\n " ) ) ;
226210 }
227211
228212 // Then, output diagnostics errors to stderr
@@ -234,10 +218,6 @@ impl WalkRunner {
234218 // Count the processed files
235219 let total_target_files_count = changed_paths. len ( ) + unchanged_count + error_count;
236220 let print_stats = |stdout, stderr| {
237- if agent_output {
238- return ;
239- }
240-
241221 utils:: print_and_flush (
242222 stdout,
243223 & format ! (
@@ -259,32 +239,24 @@ impl WalkRunner {
259239 // Check if no files were found
260240 if total_target_files_count == 0 {
261241 if runtime_options. no_error_on_unmatched_pattern {
262- if !agent_output {
263- utils:: print_and_flush ( stderr, "No files found matching the given patterns.\n " ) ;
264- print_stats ( stdout, stderr) ;
265- }
242+ utils:: print_and_flush ( stderr, "No files found matching the given patterns.\n " ) ;
243+ print_stats ( stdout, stderr) ;
266244 return CliRunResult :: None ;
267245 }
268246
269- if agent_output {
270- utils:: print_and_flush ( stderr, "No files found.\n " ) ;
271- } else {
272- utils:: print_and_flush (
273- stderr,
274- "Expected at least one target file. All matched files may have been excluded by ignore rules.\n " ,
275- ) ;
276- }
247+ utils:: print_and_flush (
248+ stderr,
249+ "Expected at least one target file. All matched files may have been excluded by ignore rules.\n " ,
250+ ) ;
277251 return CliRunResult :: NoFilesFound ;
278252 }
279253
280254 if 0 < error_count {
281255 // Each error is already printed in reporter
282- if !agent_output {
283- utils:: print_and_flush (
284- stderr,
285- "Error occurred when checking code style in the above files.\n " ,
286- ) ;
287- }
256+ utils:: print_and_flush (
257+ stderr,
258+ "Error occurred when checking code style in the above files.\n " ,
259+ ) ;
288260 return CliRunResult :: FormatFailed ;
289261 }
290262
@@ -294,23 +266,19 @@ impl WalkRunner {
294266 ( OutputMode :: ListDifferent , _) => CliRunResult :: FormatMismatch ,
295267 // `--check` outputs friendly summary
296268 ( OutputMode :: Check , 0 ) => {
297- if !agent_output {
298- utils:: print_and_flush ( stdout, "All matched files use the correct format.\n " ) ;
299- print_stats ( stdout, stderr) ;
300- }
269+ utils:: print_and_flush ( stdout, "All matched files use the correct format.\n " ) ;
270+ print_stats ( stdout, stderr) ;
301271 CliRunResult :: FormatSucceeded
302272 }
303273 ( OutputMode :: Check , changed_count) => {
304- if !agent_output {
305- utils:: print_and_flush ( stdout, "\n \n " ) ;
306- utils:: print_and_flush (
307- stdout,
308- & format ! (
309- "Format issues found in above {changed_count} files. Run without `--check` to fix.\n " ,
310- ) ,
311- ) ;
312- print_stats ( stdout, stderr) ;
313- }
274+ utils:: print_and_flush ( stdout, "\n \n " ) ;
275+ utils:: print_and_flush (
276+ stdout,
277+ & format ! (
278+ "Format issues found in above {changed_count} files. Run without `--check` to fix.\n " ,
279+ ) ,
280+ ) ;
281+ print_stats ( stdout, stderr) ;
314282 CliRunResult :: FormatMismatch
315283 }
316284 // Default (write) outputs only stats
0 commit comments