From 3a098c23c4db2c3290c00d273cb56a582ad8ad4d Mon Sep 17 00:00:00 2001 From: Jonathan Liebig Date: Tue, 22 Sep 2026 22:17:43 +0200 Subject: [PATCH] fix: detect npm-installed omp on windows refs #4313 --- src/detect/mod.rs | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/detect/mod.rs b/src/detect/mod.rs index 7fe15d111..3dae571b2 100644 --- a/src/detect/mod.rs +++ b/src/detect/mod.rs @@ -648,6 +648,15 @@ fn agent_name_from_known_package_path(path: &str) -> Option { ]) { return Some(agent_label(Agent::Pi).to_string()); } + if ends_with(&[ + "node_modules", + "@oh-my-pi", + "pi-coding-agent", + "dist", + "cli.js", + ]) { + return Some(agent_label(Agent::Omp).to_string()); + } if ends_with(&[ "node_modules", "@moonshot-ai", @@ -1433,19 +1442,36 @@ mod tests { #[test] fn identify_agent_in_job_detects_bun_wrapped_omp() { - let job = crate::platform::ForegroundJob { + for (runtime, script) in [ + ("bun", "/home/can/.bun/bin/omp"), + ( + "bun.exe", + r"C:\Users\herdr\AppData\Roaming\npm\node_modules\@oh-my-pi\pi-coding-agent\dist\cli.js", + ), + ] { + let job = crate::platform::ForegroundJob { + process_group_id: 123, + processes: vec![foreground_process(123, runtime, &[runtime, script])], + }; + assert_eq!( + identify_agent_in_job(&job), + Some((Agent::Omp, "omp".to_string())), + "script: {script}" + ); + } + + let other_script = crate::platform::ForegroundJob { process_group_id: 123, processes: vec![foreground_process( 123, - "bun", - &["bun", "/home/can/.bun/bin/omp"], + "bun.exe", + &[ + "bun.exe", + r"C:\Users\herdr\AppData\Roaming\npm\node_modules\@oh-my-pi\pi-coding-agent\dist\setup.js", + ], )], }; - - assert_eq!( - identify_agent_in_job(&job), - Some((Agent::Omp, "omp".to_string())) - ); + assert_eq!(identify_agent_in_job(&other_script), None); } #[test]