From 94455d886c9ff97badb087cbe26958cb2be656fd Mon Sep 17 00:00:00 2001 From: Abdul Wahab Date: Wed, 16 Sep 2026 14:37:41 +0500 Subject: [PATCH] Fix: pin home-rooted check to one layout so leftover user dirs cannot stale a project install Inferred scope walked both Pi paths. A current ~/.pi/skills copy next to a leftover ~/.pi/agent/skills without impeccable still hashed as outdated. Project scope on that fallback hashes only the project layout. Written with AI assistance (Cursor Grok 4.6). Co-authored-by: Cursor --- crates/skills/src/commands.rs | 16 ++++++++++------ crates/skills/tests/drift_ports_tests.rs | 5 +++++ 2 files changed, 15 insertions(+), 6 deletions(-) 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(); }