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 <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-09-16 14:37:41 +05:00
co-authored by Cursor
parent 8a97f6cd1d
commit 94455d886c
2 changed files with 15 additions and 6 deletions
+10 -6
View File
@@ -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
};
+5
View File
@@ -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();
}