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

+1
View File
@@ -59,6 +59,7 @@ pub fn builtins(models: &[&str]) -> Vec<CmdSpec> {
b("compact", "summarize old context", None),
b("clear", "start an empty session", None),
b("lsp", "language server status", None),
b("skills", "list skills and where they load from", None),
b("quit", "exit hx", None),
b("exit", "exit hx", None),
]
+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"));
}
}