skills: load ~/.agents/skills; /skills lists skills and searched dirs
ci / check (pull_request) Canceled after 0s
ci / check (push) Canceled after 0s

This commit is contained in:
hermes committed 2026-09-30 22:24:41 +00:00
1 parent 35037caa2c
commit 1d1d381516
5 files changed
+62 -7

No files matched your search

+6 -4
View File
@@ -42,12 +42,13 @@ pub struct Skill {
pub path: PathBuf,
}
/// Skill dirs, lowest priority first: `~/.agent/skills` (shared with other agents), `<hx home>/skills`,
/// `<project>/.hx/skills`.
/// Skill dirs, lowest priority first: `~/.agent/skills` and `~/.agents/skills` (shared with other
/// agents), `<hx home>/skills`, `<project>/.hx/skills`.
pub fn skill_dirs(home: &Path, cwd: &Path) -> Vec<PathBuf> {
let mut v: Vec<PathBuf> = std::env::var_os("HOME")
.map(|h| PathBuf::from(h).join(".agent/skills"))
.map(PathBuf::from)
.into_iter()
.flat_map(|h| [h.join(".agent/skills"), h.join(".agents/skills")])
.collect();
v.push(home.join("skills"));
v.push(cwd.join(".hx/skills"));
@@ -189,6 +190,7 @@ mod tests {
.collect();
assert_eq!(got, [("a", "shared"), ("g", "hx-g")]);
let d = skill_dirs(Path::new("/h"), Path::new("/p"));
assert!(d[0].ends_with(".agent/skills") && d[1] == Path::new("/h/skills"));
assert!(d[0].ends_with(".agent/skills") && d[1].ends_with(".agents/skills"));
assert!(d[2] == Path::new("/h/skills") && d[3] == Path::new("/p/.hx/skills"));
}
}