diff --git a/crates/skills/src/commands.rs b/crates/skills/src/commands.rs index 5cf4b3acd..ae6eb10d0 100644 --- a/crates/skills/src/commands.rs +++ b/crates/skills/src/commands.rs @@ -140,12 +140,16 @@ fn locale_compare(a: &str, b: &str) -> std::cmp::Ordering { fn check(io: &mut Io) -> R<()> { let (sys, _) = ctx(io); let root = sys.find_project_root(); - // Prefer the user-level tree when one exists so leftover project-layout - // dirs cannot make a current install look stale (#824). Stay on inferred - // scope otherwise so a home-rooted project install (`install -y`) is - // still visible. - let scope = if sys.is_home_dir(&root) && sys.is_already_installed(&root, Some(Scope::User)).is_some() { - Some(Scope::User) + // A home-rooted tree is either the user-level install or a project + // install under ~. Pick one scope so leftover dirs on the other layout + // cannot make a current copy look stale (#824). Inferred scope walks + // both, which is what produced the false "Updates available". + let scope = if sys.is_home_dir(&root) { + if sys.is_already_installed(&root, Some(Scope::User)).is_some() { + Some(Scope::User) + } else { + Some(Scope::Project) + } } else { None }; diff --git a/crates/skills/tests/drift_ports_tests.rs b/crates/skills/tests/drift_ports_tests.rs index 4d37efd87..b00b6c526 100644 --- a/crates/skills/tests/drift_ports_tests.rs +++ b/crates/skills/tests/drift_ports_tests.rs @@ -547,10 +547,15 @@ fn check_sees_home_rooted_project_scope_pi_install() { assert_eq!(r.code, 0, "{}\n{}", r.stdout, r.stderr); assert!(std::path::Path::new(&format!("{home}/.pi/skills/impeccable/SKILL.md")).exists()); assert!(!std::path::Path::new(&format!("{home}/.pi/agent/skills/impeccable/SKILL.md")).exists()); + write( + &format!("{home}/.pi/agent/skills/other/SKILL.md"), + "---\nname: other\n---\nLeftover user-layout skill.\n", + ); let r = run_cli(&["check"], &home, &env); assert!(!r.stdout.contains("not installed"), "{}\n{}", r.stdout, r.stderr); assert!(r.stdout.contains("Skills are up to date"), "{}\n{}", r.stdout, r.stderr); + assert!(!r.stdout.contains("Updates available"), "{}", r.stdout); std::fs::remove_dir_all(&root).ok(); }