The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: merge shipped skill categories instead of replacing them on update
teknium1fa915784cb0c
diff --git a/hermes_cli/profile_distribution.py b/hermes_cli/profile_distribution.pyindex 963abeea2be..639e550066f 100644--- a/hermes_cli/profile_distribution.py+++ b/hermes_cli/profile_distribution.py@@ -401,6 +401,30 @@ def _refuse_symlink(path: Path) -> None:)+def _is_container(path: Path) -> bool:+ """A shipped directory holding no files (a skills category) is a container of roots,+ not a root itself; a skill dir always holds at least SKILL.md."""+ return path.is_dir() and not any(p.is_file() for p in path.iterdir())+++def _merge_dir(src: Path, dest: Path) -> None:+ """Replace only the roots *src* ships inside *dest*; a nested container+ (``skills/<category>``) is merged, not replaced, so sibling roots the user+ added under the same category survive."""+ for child in src.iterdir():+ if _is_container(child):+ _merge_dir(child, _real_dir(dest, (child.name,)))+ else:+ _replace_entry(child, dest / child.name)+++def _refuse_symlinked_containers(src: Path, dest: Path) -> None:+ for child in src.iterdir():+ if _is_container(child):+ _refuse_symlink(dest / child.name)+ _refuse_symlinked_containers(child, dest / child.name)++def _refuse_symlinked_targets(target: Path, entries) -> None:"""Refuse before the first write. The per-entry check in ``_real_dir`` fires mid-loop,after earlier entries were already replaced and before the manifest is rewritten,@@ -413,6 +437,8 @@ def _refuse_symlinked_targets(target: Path, entries) -> None:for part in rel_parts[:depth]:path = path / part_refuse_symlink(path)+ if src.is_dir() and len(rel_parts) == 1:+ _refuse_symlinked_containers(src, path)def _copy_dist_payload(staged: Path, target: Path, manifest: DistributionManifest, preserve_config: bool) -> None:@@ -439,9 +465,7 @@ def _copy_dist_payload(staged: Path, target: Path, manifest: DistributionManifesif name == "config.yaml" and preserve_config and (target / "config.yaml").exists():continueif src.is_dir():- container = _real_dir(target, rel_parts)- for child in src.iterdir():- _replace_entry(child, container / child.name)+ _merge_dir(src, _real_dir(target, rel_parts))continueparent = _real_dir(target, rel_parts[:-1])_replace_entry(src, parent / rel_parts[-1])diff --git a/tests/hermes_cli/test_profile_distribution.py b/tests/hermes_cli/test_profile_distribution.pyindex 26f81e7f8c2..e0129d936e9 100644--- a/tests/hermes_cli/test_profile_distribution.py+++ b/tests/hermes_cli/test_profile_distribution.py@@ -390,10 +390,19 @@ class TestUpdate:(staged / "skills" / "demo" / "SKILL.md").write_text("updated demo\n", encoding="utf-8")(staged / "skills" / "new").mkdir()(staged / "skills" / "new" / "SKILL.md").write_text("new skill\n", encoding="utf-8")+ # Categorised skill (skills/<category>/<skill>): the category is a container too,+ # so a sibling the user added inside it survives (issue #25120's literal repro).+ (staged / "skills" / "devops" / "team-deploy").mkdir(parents=True)+ (staged / "skills" / "devops" / "team-deploy" / "SKILL.md").write_text("team deploy\n", encoding="utf-8")+ mine = plan.target_dir / "skills" / "devops" / "my-custom-skill"+ mine.mkdir(parents=True)+ (mine / "SKILL.md").write_text("my custom skill\n", encoding="utf-8")update_distribution("skills_safe")assert (custom / "SKILL.md").read_text(encoding="utf-8") == "custom skill\n"+ assert (mine / "SKILL.md").read_text(encoding="utf-8") == "my custom skill\n"+ assert (plan.target_dir / "skills" / "devops" / "team-deploy" / "SKILL.md").exists()assert (plan.target_dir / "cron" / "mine.json").read_text(encoding="utf-8") == '{"schedule": "* * * * *"}\n'assert (plan.target_dir / "skills" / "demo" / "SKILL.md").read_text(encoding="utf-8") == "updated demo\n"assert (plan.target_dir / "skills" / "new" / "SKILL.md").read_text(encoding="utf-8") == "new skill\n"@@ -413,6 +422,16 @@ class TestUpdate:(shared / "mine" / "SKILL.md").write_text("shared skill\n", encoding="utf-8")before = sorted((p.relative_to(shared), p.read_bytes()) for p in shared.rglob("*") if p.is_file())+ # A symlinked category (skills/devops -> shared dir) is a container too and is refused+ # rather than unlinked and replaced by the shipped copy.+ (staged / "skills" / "devops" / "team-deploy").mkdir(parents=True)+ (staged / "skills" / "devops" / "team-deploy" / "SKILL.md").write_text("team deploy\n", encoding="utf-8")+ _symlink_file_or_skip(plan.target_dir / "skills" / "devops", shared)+ with pytest.raises(DistributionError, match="symlink"):+ update_distribution("link_safe")+ assert (plan.target_dir / "skills" / "devops").is_symlink()+ (plan.target_dir / "skills" / "devops").unlink()+skills = plan.target_dir / "skills"shutil.rmtree(skills)_symlink_file_or_skip(skills, shared)diff --git a/website/docs/reference/profile-commands.md b/website/docs/reference/profile-commands.mdindex af90bef5be8..3d37e5b7732 100644--- a/website/docs/reference/profile-commands.md+++ b/website/docs/reference/profile-commands.md@@ -360,8 +360,8 @@ Re-clones the distribution from its recorded source and applies updates.Distribution-owned files (SOUL.md, mcp.json) are overwritten and theskills and cron jobs the distribution ships are replaced; skills or cronjobs you added under `skills/` or `cron/` yourself stay in place. User data-(memories, sessions, auth, .env) is never touched. A symlinked `skills/` or-`cron/` is refused before anything is written — replace the link with a real+(memories, sessions, auth, .env) is never touched. A symlinked `skills/`,+`cron/` or skill category directory is refused before anything is written — replace the link with a realdirectory and re-run.`config.yaml` is preserved by default to keep your local overrides.