From 1a41e71adc5bd097df7e21a54b6c089db68ff4cd Mon Sep 17 00:00:00 2001 From: hermes Date: Thu, 1 Oct 2026 06:37:07 +0000 Subject: [PATCH] skills: drop ~/.agent/skills; add project .agents/skills --- README.md | 2 +- crates/hx-core/src/context.rs | 21 +++++++++++++-------- tests/tui_smoke.py | 3 +++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 00da884..e8e8d3b 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ tests = "turn_end" # affected tests: turn_end | agent_end | off Skills are `//SKILL.md` files with `name:` / `description:` frontmatter. Only the name and description go into the system prompt; the model reads the file when a task matches. Looked up in -`~/.agent/skills` and `~/.agents/skills` (shared with other agents), `~/.hx/skills`, then `.hx/skills` in +`~/.agents/skills` (shared with other agents), `~/.hx/skills`, then `.agents/skills` and `.hx/skills` in the project; a later directory wins when names collide. `/skills` lists what loaded and the searched dirs. Each skill is also a command: `/ [args]` sends the skill file plus `args` as the prompt. Builtin diff --git a/crates/hx-core/src/context.rs b/crates/hx-core/src/context.rs index 067d294..3269f4a 100644 --- a/crates/hx-core/src/context.rs +++ b/crates/hx-core/src/context.rs @@ -42,16 +42,18 @@ pub struct Skill { pub path: PathBuf, } -/// Skill dirs, lowest priority first: `~/.agent/skills` and `~/.agents/skills` (shared with other -/// agents), `/skills`, `/.hx/skills`. +/// Skill dirs, lowest priority first: `~/.agents/skills` (shared with other agents), `/skills`, +/// `/.agents/skills`, `/.hx/skills`. pub fn skill_dirs(home: &Path, cwd: &Path) -> Vec { let mut v: Vec = std::env::var_os("HOME") - .map(PathBuf::from) + .map(|h| PathBuf::from(h).join(".agents/skills")) .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")); + v.extend([ + home.join("skills"), + cwd.join(".agents/skills"), + cwd.join(".hx/skills"), + ]); v } @@ -190,7 +192,10 @@ 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].ends_with(".agents/skills")); - assert!(d[2] == Path::new("/h/skills") && d[3] == Path::new("/p/.hx/skills")); + assert!(d[0].ends_with(".agents/skills")); + assert_eq!( + d[1..], + ["/h/skills", "/p/.agents/skills", "/p/.hx/skills"].map(PathBuf::from) + ); } } diff --git a/tests/tui_smoke.py b/tests/tui_smoke.py index 82d9f68..fba2dd6 100644 --- a/tests/tui_smoke.py +++ b/tests/tui_smoke.py @@ -9,6 +9,8 @@ os.makedirs(f"{tmp}/home/.hx"); os.makedirs(f"{tmp}/repo") open(f"{tmp}/home/.hx/auth.json", "w").write(json.dumps({"claude": {"access": "fake-token", "refresh": "r", "expires": 99999999999999}})) open(f"{tmp}/repo/notes.md", "w").write("NOTES\n") os.makedirs(f"{tmp}/home/.agents/skills/deploy") +os.makedirs(f"{tmp}/repo/.agents/skills/lint") +open(f"{tmp}/repo/.agents/skills/lint/SKILL.md", "w").write("---\nname: lint\ndescription: project lint\n---\nBODY\n") open(f"{tmp}/home/.agents/skills/deploy/SKILL.md", "w").write("---\nname: deploy\ndescription: ship it\n---\nBODY\n") time.sleep(0.5) @@ -49,6 +51,7 @@ pump(1.5) check("startup footer", "Claude") send(b"/skills\r") check("skills from ~/.agents", "/deploy — ship it") +check("project .agents skills", "/lint — project lint") send(b"@not"); send(b"\t") check("tab completion", "es.md") send(b"\x15") # ctrl-u