Skip to content

The agent that grows with you

fix(profile_distribution): a dir inside a skill stays part of that skill

kshitijk4poor436b904e80ec
diff --git a/hermes_cli/profile_distribution.py b/hermes_cli/profile_distribution.py
index 3f392108c15..6df121dc856 100644
--- a/hermes_cli/profile_distribution.py
+++ b/hermes_cli/profile_distribution.py
@@ -442,13 +442,14 @@ def _refuse_symlink(path: Path) -> None:
def _is_container(path: Path, rel: Tuple[str, ...]) -> bool:
- """A container of roots, not a root itself. Under ``skills/`` that is any dir without
- SKILL.md (a category, whatever metadata it ships: DESCRIPTION.md, README.md, LICENSE);
+ """A container of roots, not a root itself. Under ``skills/`` that is a dir with no
+ SKILL.md in it or above it (a category, whatever metadata it ships: DESCRIPTION.md,
+ README.md, LICENSE; a dir inside a skill, like its ``scripts/``, belongs to that skill);
elsewhere, a dir holding no files other than DESCRIPTION.md and dotfiles."""
if not path.is_dir():
return False
if rel[0] == "skills":
- return not (path / "SKILL.md").is_file()
+ return not any((p / "SKILL.md").is_file() for p in (path, *path.parents[: len(rel) - 1]))
return not any(
p.is_file() and p.name != "DESCRIPTION.md" and not p.name.startswith(".") for p in path.iterdir()
)
@@ -479,8 +480,8 @@ def _refuse_symlinked_containers(src: Path, dest: Path, rel: Tuple[str, ...]) ->
def _merges_per_root(src: Path, rel_parts: Tuple[str, ...]) -> bool:
- """An owned top-level dir, or an owned category (``skills/research/``) holding only
- roots, is merged per authored root instead of replaced whole, so skills the installer
+ """An owned top-level dir, or an owned container (``skills/research/``, see
+ ``_is_container``), is merged per authored root instead of replaced whole, so skills the installer
added to it (``hermes skills install`` and agent-created skills land in
``skills/<category>/``) survive. The pre-write symlink guard and the copy loop both
use this, so the guard covers exactly what the copy merges."""
@@ -510,7 +511,7 @@ def _copy_dist_payload(staged: Path, target: Path, manifest: DistributionManifes
``preserve_config`` is False (fresh install / ``--force-config``). ``.env.template`` lands
as ``.env.EXAMPLE`` so it never shadows a real ``.env``.
- A top-level owned directory, and an owned category holding only roots, is merged per
+ A top-level owned directory, and an owned container (``_is_container``), is merged per
authored root. ``cron/jobs.json`` is special: it is one multi-record runtime store, so
shipped definitions merge by job id instead of replacing the file."""
target.mkdir(parents=True, exist_ok=True)
diff --git a/tests/hermes_cli/test_profile_distribution.py b/tests/hermes_cli/test_profile_distribution.py
index 8f3f45ee0fd..41d1d045263 100644
--- a/tests/hermes_cli/test_profile_distribution.py
+++ b/tests/hermes_cli/test_profile_distribution.py
@@ -500,6 +500,11 @@ class TestUpdate:
assert (research / "arxiv" / "SKILL.md").exists()
assert (research / "DESCRIPTION.md").read_text(encoding="utf-8") == "research skills\n"
assert (research / "README.md").read_text(encoding="utf-8") == "about research\n"
+ # A dir inside a skill is part of that skill: owning ``web-search/scripts`` replaces it whole.
+ from hermes_cli.profile_distribution import _merges_per_root
+ scripts = staged / "skills" / "research" / "web-search" / "scripts"
+ scripts.mkdir()
+ assert not _merges_per_root(scripts, ("skills", "research", "web-search", "scripts"))
def test_an_owned_category_refuses_a_symlinked_subcategory_before_writing(self, profile_env, tmp_path):
staged, plan = self._owned_category(profile_env, "rb")