The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): name workspace members after their plugin dir
ethernet005780481d38
diff --git a/pm/workspace.py b/pm/workspace.pyindex ce39fab66d4..218db498bef 100644--- a/pm/workspace.py+++ b/pm/workspace.py@@ -170,12 +170,23 @@ def enabled_member_dirs(*, proposed_home=None, enabled=None, disabled=None) -> lreturn members+def _member_key(identity: Path) -> str:+ """``<plugin dir name>-<sha256(path)[:16]>``: the hash keeps two same-named plugins from+ different homes apart; the name is what a user sees in uv's conflict text+ (``hermes-plugin-<key> depends on …``) — a bare hash told them nothing to disable."""+ import re++ digest = hashlib.sha256(str(identity.resolve()).encode()).hexdigest()[:16]+ name = re.sub(r"[^a-z0-9._-]+", "-", identity.name.lower()).strip("-.") or "plugin"+ return f"{name}-{digest}"++def _workspace_member(plugin_dir: Path, root: Path, *, identity: Path) -> Path:"""Keep workspace members with their generation, not a temporary install clone."""import jsonimport tomllib- key = hashlib.sha256(str(identity.resolve()).encode()).hexdigest()[:16]+ key = _member_key(identity)declaration = read_python_declaration(plugin_dir)pyproject = declaration.pyprojectif pyproject is not None:diff --git a/tests/pm/test_member_selection.py b/tests/pm/test_member_selection.pyindex 1b6f0e4ce03..c1dd3d4aa1b 100644--- a/tests/pm/test_member_selection.py+++ b/tests/pm/test_member_selection.py@@ -16,3 +16,24 @@ def test_scoped_members_respect_disabled_and_keep_other_profiles(tmp_path, monkeassert set(enabled_member_dirs()) == {current, other}(home / "config.yaml").write_text('plugins:\n enabled: [group/plugin]\n disabled: [group/plugin]\n')assert enabled_member_dirs() == [other]+++def test_manifest_only_member_is_named_after_its_plugin_dir_and_stays_unique(tmp_path):+ """uv's conflict text names the workspace member (``hermes-plugin-<key> depends on …``);+ a bare path hash left the user with nothing to disable. Two same-named plugins from+ different homes must still be distinct members."""+ import tomllib+ from pm.workspace import _workspace_member++ members = []+ for home in ("home-a", "home-b"):+ plugin = tmp_path / home / "plugins" / "My Plugin!"+ plugin.mkdir(parents=True)+ (plugin / "plugin.yaml").write_text("name: my-plugin\npip_dependencies: [left-pad-py]\n", encoding="utf-8")+ root = tmp_path / f"gen-{home}"+ root.mkdir()+ members.append(_workspace_member(plugin, root, identity=plugin))+ names = [tomllib.loads((m / "pyproject.toml").read_text(encoding="utf-8"))["project"]["name"] for m in members]+ assert all(name.startswith("hermes-plugin-my-plugin-") for name in names), names+ assert names[0] != names[1]+ assert members[0].name != members[1].name