From 677afc1fc2c3e81b0cd51eb07c5efb4c5ac7ece7 Mon Sep 17 00:00:00 2001 From: haelyra <49814733+haelyra@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:01:55 -0500 Subject: [PATCH] fix(ecc2): detect bun.lock and npm-shrinkwrap.json lockfiles The ECC 2 session launcher picked the package manager from lockfiles but only knew bun.lockb and package-lock.json. Bun 1.2+ writes the text bun.lock by default, so those projects fell through to npm. Match the Node detector in scripts/lib/package-manager.js, which already accepts bun.lock, bun.lockb, package-lock.json, and npm-shrinkwrap.json, while keeping the pnpm > bun > yarn > npm priority. Carries forward the lockfile-alias parity from #2998. Co-authored-by: mawquf28 <325559970+mawquf28@users.noreply.github.com> --- ecc2/src/session/manager.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ecc2/src/session/manager.rs b/ecc2/src/session/manager.rs index 2871e6188..586975f7d 100644 --- a/ecc2/src/session/manager.rs +++ b/ecc2/src/session/manager.rs @@ -3437,9 +3437,12 @@ fn read_package_manager_from_package_json(path: &Path) -> Option<&'static str> { fn detect_package_manager_from_lockfile(working_dir: &Path) -> Option<&'static str> { [ ("pnpm", "pnpm-lock.yaml"), + // Bun 1.2+ writes the text bun.lock by default; keep the legacy binary lockfile. + ("bun", "bun.lock"), ("bun", "bun.lockb"), ("yarn", "yarn.lock"), ("npm", "package-lock.json"), + ("npm", "npm-shrinkwrap.json"), ] .into_iter() .find_map(|(package_manager, lockfile)| { @@ -4859,6 +4862,26 @@ mod tests { Ok(()) } + #[test] + fn detect_package_manager_from_lockfile_matches_node_lockfile_aliases() -> Result<()> { + for (lockfile, expected) in [ + ("bun.lock", "bun"), + ("bun.lockb", "bun"), + ("npm-shrinkwrap.json", "npm"), + ] { + let tempdir = TestDir::new("manager-package-manager-lockfile-alias")?; + let repo_root = tempdir.path().join("repo"); + fs::create_dir_all(&repo_root)?; + fs::write(repo_root.join(lockfile), "lockfile\n")?; + assert_eq!( + detect_package_manager_from_lockfile(&repo_root), + Some(expected), + "{lockfile} should select {expected}" + ); + } + Ok(()) + } + #[test] fn build_agent_command_prefers_project_package_manager_config_over_lockfile() -> Result<()> { let tempdir = TestDir::new("manager-package-manager-config")?;