1mod assertions;
2mod example;
3mod examples;
4mod explorer;
5mod ids;
6mod instance;
7mod tool_metrics;
8
9use assertions::{AssertionsReport, display_error_row};
10use instance::{ExampleInstance, JudgeOutput, RunOutput, run_git};
11use language_extension::LspAccess;
12pub(crate) use tool_metrics::*;
13
14use ::fs::RealFs;
15use clap::Parser;
16use client::{Client, ProxySettings, UserStore};
17use collections::{HashMap, HashSet};
18use extension::ExtensionHostProxy;
19use futures::future;
20use gpui::http_client::read_proxy_from_env;
21use gpui::{App, AppContext, Application, AsyncApp, Entity, UpdateGlobal};
22use gpui_tokio::Tokio;
23use language::LanguageRegistry;
24use language_model::{ConfiguredModel, LanguageModel, LanguageModelRegistry, SelectedModel};
25use node_runtime::{NodeBinaryOptions, NodeRuntime};
26use project::project_settings::ProjectSettings;
27use prompt_store::PromptBuilder;
28use release_channel::{AppCommitSha, AppVersion};
29use reqwest_client::ReqwestClient;
30use settings::{Settings, SettingsStore};
31use std::cell::RefCell;
32use std::collections::VecDeque;
33use std::env;
34use std::path::{Path, PathBuf};
35use std::rc::Rc;
36use std::str::FromStr;
37use std::sync::{Arc, LazyLock};
38use util::ResultExt as _;
39
40static CARGO_MANIFEST_DIR: LazyLock<PathBuf> =
41 LazyLock::new(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")));
42
43#[derive(Parser, Debug)]
44#[command(name = "eval", disable_version_flag = true)]
45struct Args {
46 /// Runs all examples and threads that contain these substrings. If unspecified, all examples and threads are run.
47 #[arg(value_name = "EXAMPLE_SUBSTRING")]
48 filter: Vec<String>,
49 /// provider/model to use for agent
50 #[arg(long, default_value = "anthropic/claude-3-7-sonnet-latest")]
51 model: String,
52 /// provider/model to use for judges
53 #[arg(long, default_value = "anthropic/claude-3-7-sonnet-latest")]
54 judge_model: String,
55 #[arg(long, value_delimiter = ',', default_value = "rs,ts,py")]
56 languages: Vec<String>,
57 /// How many times to run each example.
58 #[arg(long, default_value = "8")]
59 repetitions: usize,
60 /// Maximum number of examples to run concurrently.
61 #[arg(long, default_value = "4")]
62 concurrency: usize,
63 /// Output current environment variables as JSON to stdout
64 #[arg(long, hide = true)]
65 printenv: bool,
66}
67
68fn main() {
69 let args = Args::parse();
70
71 // This prevents errors showing up in the logs, because
72 // project::environment::load_shell_environment() calls
73 // std::env::current_exe().unwrap() --printenv
74 if args.printenv {
75 util::shell_env::print_env();
76 return;
77 }
78
79 dotenvy::from_filename(CARGO_MANIFEST_DIR.join(".env")).ok();
80
81 env_logger::init();
82
83 let system_id = ids::get_or_create_id(&ids::eval_system_id_path()).ok();
84 let installation_id = ids::get_or_create_id(&ids::eval_installation_id_path()).ok();
85 let session_id = uuid::Uuid::new_v4().to_string();
86 let run_timestamp = chrono::Local::now().format("%Y-%m-%d_%H-%M-%S");
87 let run_id = match env::var("GITHUB_RUN_ID") {
88 Ok(run_id) => format!("github/{}", run_id),
89 Err(_) => format!("local/{}", run_timestamp),
90 };
91
92 let root_dir = Path::new(std::env!("CARGO_MANIFEST_DIR"))
93 .parent()
94 .unwrap()
95 .parent()
96 .unwrap()
97 .canonicalize()
98 .unwrap();
99 let eval_crate_dir = root_dir.join("crates").join("eval");
100 let repos_dir = eval_crate_dir.join("repos");
101 let worktrees_dir = eval_crate_dir.join("worktrees");
102 let examples_dir = eval_crate_dir.join("src").join("examples");
103 let run_dir = eval_crate_dir
104 .join("runs")
105 .join(format!("{}", run_timestamp));
106 std::fs::create_dir_all(&run_dir).unwrap();
107 std::fs::create_dir_all(&repos_dir).unwrap();
108 std::fs::create_dir_all(&worktrees_dir).unwrap();
109 std::fs::create_dir_all(&examples_dir).unwrap();
110 std::fs::create_dir_all(&paths::config_dir()).unwrap();
111
112 let zed_commit_sha = commit_sha_for_path(&root_dir);
113 let zed_branch_name = git_branch_for_path(&root_dir);
114 let languages: HashSet<String> = args.languages.into_iter().collect();
115
116 let http_client = Arc::new(ReqwestClient::new());
117 let app = Application::headless().with_http_client(http_client);
118 let all_threads = examples::all(&examples_dir);
119
120 app.run(move |cx| {
121 let app_state = init(cx);
122
123 let telemetry = app_state.client.telemetry();
124 telemetry.start(system_id, installation_id, session_id, cx);
125
126 let enable_telemetry = env::var("ZED_EVAL_TELEMETRY").is_ok_and(|value| value == "1")
127 && telemetry.has_checksum_seed();
128 if enable_telemetry {
129 println!("Telemetry enabled");
130 telemetry::event!(
131 "Agent Eval Started",
132 zed_commit_sha = zed_commit_sha,
133 zed_branch_name = zed_branch_name,
134 run_id = run_id,
135 );
136 }
137
138 let mut cumulative_tool_metrics = ToolMetrics::default();
139
140 let tasks = LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
141 registry.providers().iter().map(|p| p.authenticate(cx)).collect::<Vec<_>>()
142 });
143
144 cx.spawn(async move |cx| {
145 future::join_all(tasks).await;
146 let judge_model = cx.update(|cx| {
147 let agent_model = load_model(&args.model, cx).unwrap();
148 let judge_model = load_model(&args.judge_model, cx).unwrap();
149 LanguageModelRegistry::global(cx).update(cx, |registry, cx| {
150 registry.set_default_model(Some(agent_model.clone()), cx);
151 });
152 judge_model
153 });
154
155 let mut examples = Vec::new();
156
157 const COLORS: [&str; 12] = [
158 "\x1b[31m", // Red
159 "\x1b[32m", // Green
160 "\x1b[33m", // Yellow
161 "\x1b[34m", // Blue
162 "\x1b[35m", // Magenta
163 "\x1b[36m", // Cyan
164 "\x1b[91m", // Bright Red
165 "\x1b[92m", // Bright Green
166 "\x1b[93m", // Bright Yellow
167 "\x1b[94m", // Bright Blue
168 "\x1b[95m", // Bright Magenta
169 "\x1b[96m", // Bright Cyan
170 ];
171
172 let mut skipped = Vec::new();
173
174 for thread in all_threads {
175 let meta = thread.meta();
176 if !args.filter.is_empty() && !args.filter.iter().any(|sub| meta.name.contains(sub))
177 {
178 skipped.push(meta.name);
179 continue;
180 }
181
182 if let Some(language) = meta.language_server
183 && !languages.contains(&language.file_extension) {
184 panic!(
185 "Eval for {:?} could not be run because no language server was found for extension {:?}",
186 meta.name,
187 language.file_extension
188 );
189 }
190
191 // TODO: This creates a worktree per repetition. Ideally these examples should
192 // either be run sequentially on the same worktree, or reuse worktrees when there
193 // are more examples to run than the concurrency limit.
194 for repetition_number in 0..args.repetitions {
195 let example_instance = ExampleInstance::new(
196 thread.clone(),
197 &repos_dir,
198 &run_dir,
199 &worktrees_dir,
200 repetition_number,
201 );
202
203 examples.push(example_instance);
204 }
205 }
206
207 if !skipped.is_empty() {
208 println!("Skipped threads: {}", skipped.join(", "));
209 }
210
211 if examples.is_empty() {
212 eprintln!("Filter matched no examples");
213 cx.update(|cx| cx.quit());
214 return anyhow::Ok(());
215 }
216
217 let mut repo_urls = HashSet::default();
218 let mut clone_tasks = Vec::new();
219
220 let max_name_width = examples
221 .iter()
222 .map(|e| e.worktree_name().len())
223 .max()
224 .unwrap_or(0);
225
226 for (i, example_instance) in examples.iter_mut().enumerate() {
227 let color = COLORS[i % COLORS.len()].to_string();
228 example_instance.set_log_prefix_style(&color, max_name_width);
229
230 println!(
231 "{}Logging to: {}",
232 example_instance.log_prefix,
233 example_instance.run_directory.display()
234 );
235
236 let repo_url = example_instance.repo_url();
237 if repo_urls.insert(repo_url.clone()) {
238 let repo_path = example_instance.repo_path.clone();
239
240 if !repo_path.join(".git").is_dir() {
241 println!(
242 "{:<width$} < {}",
243 "↓ Cloning",
244 repo_url,
245 width = max_name_width
246 );
247
248 let git_task = cx.spawn(async move |_cx| {
249 std::fs::create_dir_all(&repo_path)?;
250 run_git(&repo_path, &["init"]).await?;
251 run_git(&repo_path, &["remote", "add", "origin", &repo_url]).await
252 });
253
254 clone_tasks.push(git_task);
255 } else {
256 println!(
257 "{:<width$} < {}",
258 "✔︎ Already cloned",
259 repo_url,
260 width = max_name_width
261 );
262
263 let actual_origin =
264 run_git(&repo_path, &["remote", "get-url", "origin"]).await?;
265 anyhow::ensure!(
266 actual_origin == repo_url,
267 "remote origin {actual_origin} does not match expected origin {repo_url}"
268 );
269 }
270 }
271 }
272
273 future::join_all(clone_tasks).await;
274
275 for example_instance in examples.iter_mut() {
276 example_instance.fetch().await?;
277 }
278
279 let examples = Rc::new(RefCell::new(VecDeque::from(examples)));
280 let results_by_example_name = Rc::new(RefCell::new(HashMap::default()));
281
282 future::join_all((0..args.concurrency).map(|_| {
283 let app_state = app_state.clone();
284 let judge_model = judge_model.model.clone();
285 let zed_commit_sha = zed_commit_sha.clone();
286 let zed_branch_name = zed_branch_name.clone();
287 let run_id = run_id.clone();
288 let examples = examples.clone();
289 let results = results_by_example_name.clone();
290 cx.spawn(async move |cx| {
291 loop {
292 let Some(mut example) = examples.borrow_mut().pop_front() else {
293 break;
294 };
295 let result = async {
296 example.setup().await?;
297 let run_output = cx
298 .update(|cx| example.run(app_state.clone(), cx))
299 .await?;
300 let judge_output = judge_example(
301 example.clone(),
302 judge_model.clone(),
303 &zed_commit_sha,
304 &zed_branch_name,
305 &run_id,
306 &run_output,
307 enable_telemetry,
308 cx,
309 )
310 .await;
311 anyhow::Ok((run_output, judge_output))
312 }
313 .await;
314 results
315 .borrow_mut()
316 .entry(example.name.clone())
317 .or_insert(Vec::new())
318 .push((example.clone(), result));
319 }
320 })
321 }))
322 .await;
323
324 print_report(
325 &mut results_by_example_name.borrow_mut(),
326 &mut cumulative_tool_metrics,
327 &run_dir,
328 )?;
329
330 app_state.client.telemetry().flush_events().await;
331
332 cx.update(|cx| cx.quit());
333 anyhow::Ok(())
334 })
335 .detach_and_log_err(cx);
336 });
337}
338
339/// Subset of `workspace::AppState` needed by `HeadlessAssistant`, with additional fields.
340pub struct AgentAppState {
341 pub languages: Arc<LanguageRegistry>,
342 pub client: Arc<Client>,
343 pub user_store: Entity<UserStore>,
344 pub fs: Arc<dyn fs::Fs>,
345 pub node_runtime: NodeRuntime,
346
347 // Additional fields not present in `workspace::AppState`.
348 pub prompt_builder: Arc<PromptBuilder>,
349}
350
351pub fn init(cx: &mut App) -> Arc<AgentAppState> {
352 let app_commit_sha = option_env!("ZED_COMMIT_SHA").map(|s| AppCommitSha::new(s.to_owned()));
353
354 let app_version = AppVersion::load(
355 env!("ZED_PKG_VERSION"),
356 option_env!("ZED_BUILD_ID"),
357 app_commit_sha,
358 );
359
360 release_channel::init(app_version.clone(), cx);
361 gpui_tokio::init(cx);
362
363 let settings_store = SettingsStore::new(cx, &settings::default_settings());
364 cx.set_global(settings_store);
365
366 // Set User-Agent so we can download language servers from GitHub
367 let user_agent = format!(
368 "Zed Agent Eval/{} ({}; {})",
369 app_version,
370 std::env::consts::OS,
371 std::env::consts::ARCH
372 );
373 let proxy_str = ProxySettings::get_global(cx).proxy.to_owned();
374 let proxy_url = proxy_str
375 .as_ref()
376 .and_then(|input| input.parse().ok())
377 .or_else(read_proxy_from_env);
378 let http = {
379 let _guard = Tokio::handle(cx).enter();
380
381 ReqwestClient::proxy_and_user_agent(proxy_url, &user_agent)
382 .expect("could not start HTTP client")
383 };
384 cx.set_http_client(Arc::new(http));
385
386 let client = Client::production(cx);
387 cx.set_http_client(client.http_client());
388
389 let git_binary_path = None;
390 let fs = Arc::new(RealFs::new(
391 git_binary_path,
392 cx.background_executor().clone(),
393 ));
394
395 let mut languages = LanguageRegistry::new(cx.background_executor().clone());
396 languages.set_language_server_download_dir(paths::languages_dir().clone());
397 let languages = Arc::new(languages);
398
399 let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
400
401 extension::init(cx);
402
403 let (mut tx, rx) = watch::channel(None);
404 cx.observe_global::<SettingsStore>(move |cx| {
405 let settings = &ProjectSettings::get_global(cx).node;
406 let options = NodeBinaryOptions {
407 allow_path_lookup: !settings.ignore_system_version,
408 allow_binary_download: true,
409 use_paths: settings.path.as_ref().map(|node_path| {
410 let node_path = PathBuf::from(shellexpand::tilde(node_path).as_ref());
411 let npm_path = settings
412 .npm_path
413 .as_ref()
414 .map(|path| PathBuf::from(shellexpand::tilde(&path).as_ref()));
415 (
416 node_path.clone(),
417 npm_path.unwrap_or_else(|| {
418 let base_path = PathBuf::new();
419 node_path.parent().unwrap_or(&base_path).join("npm")
420 }),
421 )
422 }),
423 };
424 tx.send(Some(options)).log_err();
425 })
426 .detach();
427 let node_runtime = NodeRuntime::new(client.http_client(), None, rx);
428
429 let extension_host_proxy = ExtensionHostProxy::global(cx);
430 debug_adapter_extension::init(extension_host_proxy.clone(), cx);
431 language_extension::init(LspAccess::Noop, extension_host_proxy, languages.clone());
432 language_model::init(client.clone(), cx);
433 language_models::init(user_store.clone(), client.clone(), cx);
434 languages::init(languages.clone(), fs.clone(), node_runtime.clone(), cx);
435 prompt_store::init(cx);
436 terminal_view::init(cx);
437 let stdout_is_a_pty = false;
438 let prompt_builder = PromptBuilder::load(fs.clone(), stdout_is_a_pty, cx);
439 agent_ui::init(
440 fs.clone(),
441 client.clone(),
442 prompt_builder.clone(),
443 languages.clone(),
444 true,
445 cx,
446 );
447
448 SettingsStore::update_global(cx, |store, cx| {
449 store.set_user_settings(include_str!("../runner_settings.json"), cx)
450 })
451 .unwrap();
452
453 Arc::new(AgentAppState {
454 languages,
455 client,
456 user_store,
457 fs,
458 node_runtime,
459 prompt_builder,
460 })
461}
462
463pub fn find_model(
464 model_name: &str,
465 model_registry: &LanguageModelRegistry,
466 cx: &App,
467) -> anyhow::Result<Arc<dyn LanguageModel>> {
468 let selected = SelectedModel::from_str(model_name).map_err(|e| anyhow::anyhow!(e))?;
469 model_registry
470 .available_models(cx)
471 .find(|model| model.id() == selected.model && model.provider_id() == selected.provider)
472 .ok_or_else(|| {
473 anyhow::anyhow!(
474 "No language model with ID {}/{} was available. Available models: {}",
475 selected.provider.0,
476 selected.model.0,
477 model_registry
478 .available_models(cx)
479 .map(|model| format!("{}/{}", model.provider_id().0, model.id().0))
480 .collect::<Vec<_>>()
481 .join(", ")
482 )
483 })
484}
485
486pub fn load_model(model_name: &str, cx: &mut App) -> anyhow::Result<ConfiguredModel> {
487 let model = {
488 let model_registry = LanguageModelRegistry::read_global(cx);
489 find_model(model_name, model_registry, cx)?
490 };
491
492 let provider = {
493 let model_registry = LanguageModelRegistry::read_global(cx);
494 model_registry
495 .provider(&model.provider_id())
496 .ok_or_else(|| anyhow::anyhow!("Provider not found: {}", model.provider_id()))?
497 };
498
499 Ok(ConfiguredModel {
500 provider: provider.clone(),
501 model: model.clone(),
502 })
503}
504
505pub fn commit_sha_for_path(repo_path: &Path) -> String {
506 futures::executor::block_on(run_git(repo_path, &["rev-parse", "HEAD"])).unwrap()
507}
508
509pub fn git_branch_for_path(repo_path: &Path) -> String {
510 match std::env::var("GITHUB_REF_NAME") {
511 Ok(branch) => branch,
512 Err(_) => {
513 futures::executor::block_on(run_git(repo_path, &["rev-parse", "--abbrev-ref", "HEAD"]))
514 .unwrap_or_else(|_| "unknown".to_string())
515 }
516 }
517}
518
519async fn judge_example(
520 example: ExampleInstance,
521 model: Arc<dyn LanguageModel>,
522 zed_commit_sha: &str,
523 zed_branch_name: &str,
524 run_id: &str,
525 run_output: &RunOutput,
526 enable_telemetry: bool,
527 cx: &AsyncApp,
528) -> JudgeOutput {
529 let judge_output = example.judge(model.clone(), run_output, cx).await;
530
531 if enable_telemetry {
532 telemetry::event!(
533 "Agent Example Evaluated",
534 zed_commit_sha = zed_commit_sha,
535 zed_branch_name = zed_branch_name,
536 run_id = run_id,
537 example_name = example.name.clone(),
538 example_repetition = example.repetition,
539 diff_evaluation = judge_output.diff.clone(),
540 thread_evaluation = judge_output.thread,
541 tool_metrics = run_output.tool_metrics,
542 token_usage = run_output.token_usage,
543 model = model.telemetry_id(),
544 model_provider = model.provider_id().to_string(),
545 repository_url = example.repo_url(),
546 repository_revision = example.revision(),
547 diagnostic_summary_before = run_output.diagnostic_summary_before,
548 diagnostic_summary_after = run_output.diagnostic_summary_after,
549 diagnostics_before = run_output.diagnostics_before,
550 diagnostics_after = run_output.diagnostics_after,
551 );
552 }
553
554 judge_output
555}
556
557const HEADER_WIDTH: usize = 65;
558
559fn print_h1(header: &str) {
560 println!("\n\n{:=^HEADER_WIDTH$}", "");
561 println!("{:^HEADER_WIDTH$}", header);
562 println!("{:=^HEADER_WIDTH$}\n", "");
563}
564
565fn print_h2(header: &str) {
566 println!("\n{:-^HEADER_WIDTH$}", "");
567 println!("{:^HEADER_WIDTH$}", header);
568 println!("{:-^HEADER_WIDTH$}\n", "");
569}
570
571fn print_report(
572 results_by_example_name: &mut HashMap<
573 String,
574 Vec<(ExampleInstance, anyhow::Result<(RunOutput, JudgeOutput)>)>,
575 >,
576 cumulative_tool_metrics: &mut ToolMetrics,
577 run_dir: &Path,
578) -> anyhow::Result<()> {
579 print_h1("EVAL RESULTS");
580
581 let mut diff_scores = Vec::new();
582 let mut thread_scores = Vec::new();
583 let mut programmatic_scores = Vec::new();
584 let mut error_count = 0;
585
586 for (example_name, results) in results_by_example_name.iter_mut() {
587 print_h2(example_name);
588
589 results.sort_unstable_by_key(|(example, _)| example.repetition);
590 let mut example_cumulative_tool_metrics = ToolMetrics::default();
591
592 let mut table_rows = String::new();
593
594 for (example, result) in results.iter() {
595 match result {
596 Err(err) => {
597 display_error_row(&mut table_rows, example.repetition, err.to_string())?;
598 error_count += 1;
599 programmatic_scores.push(0.0);
600 diff_scores.push(0.0);
601 thread_scores.push(0.0);
602 }
603 Ok((run_output, judge_output)) => {
604 cumulative_tool_metrics.merge(&run_output.tool_metrics);
605 example_cumulative_tool_metrics.merge(&run_output.tool_metrics);
606
607 if run_output.programmatic_assertions.total_count() > 0 {
608 for assertion in &run_output.programmatic_assertions.ran {
609 assertions::display_table_row(
610 &mut table_rows,
611 example.repetition,
612 assertion,
613 )?;
614 }
615
616 programmatic_scores
617 .push(run_output.programmatic_assertions.passed_percentage())
618 }
619
620 if !judge_output.diff.is_empty() {
621 diff_scores.push(judge_output.diff.passed_percentage());
622
623 for assertion in &judge_output.diff.ran {
624 assertions::display_table_row(
625 &mut table_rows,
626 example.repetition,
627 assertion,
628 )?;
629 }
630 }
631
632 if !judge_output.thread.is_empty() {
633 thread_scores.push(judge_output.thread.passed_percentage());
634
635 for assertion in &judge_output.thread.ran {
636 assertions::display_table_row(
637 &mut table_rows,
638 example.repetition,
639 assertion,
640 )?;
641 }
642 }
643 }
644 }
645 }
646
647 let mut all_asserts = Vec::new();
648
649 if !table_rows.is_empty() {
650 assertions::print_table_header();
651 print!("{}", table_rows);
652
653 assertions::print_table_divider();
654
655 for (example, result) in results.iter() {
656 if let Ok((run_output, judge_output)) = result {
657 let asserts = [
658 run_output.programmatic_assertions.clone(),
659 judge_output.diff.clone(),
660 judge_output.thread.clone(),
661 ];
662 all_asserts.extend_from_slice(&asserts);
663 assertions::print_table_round_summary(
664 &example.repetition.to_string(),
665 asserts.iter(),
666 )
667 } else if let Err(err) = result {
668 let assert = AssertionsReport::error(err.to_string());
669 all_asserts.push(assert.clone());
670 assertions::print_table_round_summary(
671 &example.repetition.to_string(),
672 [assert].iter(),
673 )
674 }
675 }
676
677 assertions::print_table_divider();
678
679 assertions::print_table_round_summary("avg", all_asserts.iter());
680
681 assertions::print_table_footer();
682 }
683
684 if !example_cumulative_tool_metrics.is_empty() {
685 println!("{}", &example_cumulative_tool_metrics);
686 }
687 }
688
689 if results_by_example_name.len() > 1 {
690 print_h1("AGGREGATE");
691
692 if error_count > 0 {
693 println!("\n{error_count} examples failed to run!");
694 }
695
696 let programmatic_score_count = programmatic_scores.len();
697 if programmatic_score_count > 0 {
698 let average_programmatic_score = (programmatic_scores.into_iter().sum::<f32>()
699 / (programmatic_score_count as f32))
700 .floor();
701 println!("Average programmatic score: {average_programmatic_score}%");
702 }
703
704 let diff_score_count = diff_scores.len();
705 if diff_score_count > 0 {
706 let average_diff_score =
707 (diff_scores.into_iter().sum::<f32>() / (diff_score_count as f32)).floor();
708 println!("Average diff score: {average_diff_score}%");
709 }
710
711 let thread_score_count = thread_scores.len();
712
713 if thread_score_count > 0 {
714 let average_thread_score =
715 (thread_scores.into_iter().sum::<f32>() / (thread_score_count as f32)).floor();
716 println!("Average thread score: {average_thread_score}%");
717 }
718
719 println!();
720
721 print_h2("CUMULATIVE TOOL METRICS");
722 println!("{}", cumulative_tool_metrics);
723 }
724
725 let explorer_output_path = run_dir.join("overview.html");
726 let mut json_paths: Vec<PathBuf> = results_by_example_name
727 .values()
728 .flat_map(|results| {
729 results.iter().map(|(example, _)| {
730 let absolute_path = run_dir.join(example.run_directory.join("last.messages.json"));
731 let cwd = std::env::current_dir().expect("Can't get current dir");
732 pathdiff::diff_paths(&absolute_path, cwd).unwrap_or_else(|| absolute_path.clone())
733 })
734 })
735 .collect::<Vec<_>>();
736 json_paths.sort();
737 if let Err(err) = explorer::generate_explorer_html(&json_paths, &explorer_output_path) {
738 eprintln!("Failed to generate explorer HTML: {}", err);
739 }
740
741 Ok(())
742}