The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop-plugins): install and remove treat a Windows junction as a link
kshitijk4poor016b76da3a8a
diff --git a/hermes_cli/desktop_plugin_install.py b/hermes_cli/desktop_plugin_install.pyindex 377337ad1e2..cd900951d17 100644--- a/hermes_cli/desktop_plugin_install.py+++ b/hermes_cli/desktop_plugin_install.py@@ -133,7 +133,7 @@ def install_desktop_plugin(identifier: str, *, ref: Optional[str], catalog_name:"sourceMtimeMs": halves.mtime_ms((source_dir / "plugin.js").stat())} if package_name else None# The exists check and the publish must not interleave with a reconcile pass.with halves.ROOT_WRITER:- if (target.is_symlink() or target.exists()) and not force:+ if (halves._is_link(target) or target.exists()) and not force:return _failure(f"Desktop plugin '{folder}' already exists. Enable force reinstall to replace it.")halves.publish_desktop_tree(source_dir, target, marker)except pc.PluginOperationError as exc:@@ -167,7 +167,7 @@ def remove_desktop_plugin(name: str, *, force: bool = False) -> dict[str, Any]:except _pc().PluginOperationError as exc:return _failure(str(exc))target = desktop_plugins_root() / folder- if target.is_symlink():+ if halves._is_link(target):return _failure(f"'{folder}' is linked from somewhere else on this host; remove that link where it lives.")diff --git a/tests/hermes_cli/test_desktop_plugin_install.py b/tests/hermes_cli/test_desktop_plugin_install.pyindex 5d478766cda..0efc9e0ec37 100644--- a/tests/hermes_cli/test_desktop_plugin_install.py+++ b/tests/hermes_cli/test_desktop_plugin_install.py@@ -15,6 +15,7 @@ from types import SimpleNamespaceimport pytest+from hermes_cli import desktop_plugin_halves as halvesfrom hermes_cli import desktop_plugin_install as installURL = "https://example.invalid/acme/gizmo.git"@@ -206,6 +207,34 @@ def test_remove_leaves_a_linked_plugin_alone_and_names_nothing_outside_the_root(assert "No desktop plugin named 'ghost'" in install.remove_desktop_plugin("ghost")["error"]+def _stub_junction(monkeypatch, path: Path) -> None:+ """Report *path* as a junction, the reparse tag Windows gives a folder linked without privilege."""+ monkeypatch.setattr(halves, "is_junction", lambda p: os.fspath(p) == os.fspath(path))+++def test_remove_leaves_a_folder_the_host_reports_as_a_junction_alone(home, monkeypatch):+ root = _root(home)+ (root / "dev").mkdir(parents=True)+ (root / "dev" / "plugin.js").write_text("export default {}\n", encoding="utf-8")+ _stub_junction(monkeypatch, root / "dev")++ result = install.remove_desktop_plugin("dev", force=True)++ assert result["ok"] is False and "linked from somewhere else" in result["error"]+ assert (root / "dev" / "plugin.js").is_file()+++def test_install_does_not_replace_a_dangling_junction_without_force(home, repo, monkeypatch):+ # A junction whose target is gone answers False to exists() and to is_symlink().+ sha = _commit(repo, {"plugin.js": "export default {}\n"})+ _stub_junction(monkeypatch, _root(home) / "gizmo")++ result = install.install_desktop_plugin(URL, ref=sha)++ assert result["ok"] is False and "already exists" in result["error"]+ assert not (_root(home) / "gizmo").exists()++@pytest.mark.parametrize("name", ["C:", "C:..", "D:outside", "nul .js", "CON", "nul.txt", "Com1", "LPT¹.js", "CONIN$", "clock$.js", "gizmo."])def test_remove_refuses_a_name_windows_reads_as_a_drive_or_a_device(home, name):# On Windows, root / "C:" is the root itself and root / "C:.." its parent: a delete would wipe them.