mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-20 05:01:30 +00:00
feat: add ensure_dependency() wrapper + ship install.sh in wheel
Includes paired change: browser tool now searches ~/.hermes/node_modules/.bin/ for agent-browser installed via install.sh --ensure browser.
This commit is contained in:
parent
bea96e5cac
commit
259ae846c8
5 changed files with 147 additions and 2 deletions
43
tests/hermes_cli/test_dep_ensure.py
Normal file
43
tests/hermes_cli/test_dep_ensure.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
def test_ensure_dependency_skips_when_present():
|
||||
"""ensure_dependency is a no-op when the dep is already available."""
|
||||
from hermes_cli.dep_ensure import ensure_dependency
|
||||
with patch("hermes_cli.dep_ensure.shutil") as mock_shutil:
|
||||
mock_shutil.which.return_value = "/usr/bin/node"
|
||||
result = ensure_dependency("node", interactive=False)
|
||||
assert result is True
|
||||
|
||||
|
||||
def test_ensure_dependency_returns_false_when_missing_noninteractive():
|
||||
"""ensure_dependency returns False for missing dep in non-interactive mode."""
|
||||
from hermes_cli.dep_ensure import ensure_dependency
|
||||
with patch("hermes_cli.dep_ensure.shutil") as mock_shutil:
|
||||
mock_shutil.which.return_value = None
|
||||
with patch("hermes_cli.dep_ensure._find_install_script", return_value=None):
|
||||
result = ensure_dependency("node", interactive=False)
|
||||
assert result is False
|
||||
|
||||
|
||||
def test_find_install_script_from_checkout(tmp_path):
|
||||
"""_find_install_script finds scripts/install.sh in a git checkout."""
|
||||
from hermes_cli.dep_ensure import _find_install_script
|
||||
scripts_dir = tmp_path / "scripts"
|
||||
scripts_dir.mkdir()
|
||||
(scripts_dir / "install.sh").write_text("#!/bin/bash", encoding="utf-8")
|
||||
result = _find_install_script(package_dir=tmp_path / "hermes_cli", repo_root=tmp_path)
|
||||
assert result is not None
|
||||
assert result.name == "install.sh"
|
||||
|
||||
|
||||
def test_find_install_script_from_wheel(tmp_path):
|
||||
"""_find_install_script finds bundled install.sh in a wheel."""
|
||||
from hermes_cli.dep_ensure import _find_install_script
|
||||
bundled = tmp_path / "hermes_cli" / "scripts"
|
||||
bundled.mkdir(parents=True)
|
||||
(bundled / "install.sh").write_text("#!/bin/bash", encoding="utf-8")
|
||||
result = _find_install_script(package_dir=tmp_path / "hermes_cli", repo_root=tmp_path)
|
||||
assert result is not None
|
||||
assert result.name == "install.sh"
|
||||
Loading…
Add table
Add a link
Reference in a new issue