Merge PR #704: fix: initialize Skills Hub before listing skills
Authored by PeterFile. Fixes #703.
This commit is contained in:
commit
2e73a9e893
2 changed files with 33 additions and 1 deletions
|
|
@ -408,10 +408,11 @@ def do_inspect(identifier: str, console: Optional[Console] = None) -> None:
|
||||||
|
|
||||||
def do_list(source_filter: str = "all", console: Optional[Console] = None) -> None:
|
def do_list(source_filter: str = "all", console: Optional[Console] = None) -> None:
|
||||||
"""List installed skills, distinguishing builtins from hub-installed."""
|
"""List installed skills, distinguishing builtins from hub-installed."""
|
||||||
from tools.skills_hub import HubLockFile, SKILLS_DIR
|
from tools.skills_hub import HubLockFile, ensure_hub_dirs
|
||||||
from tools.skills_tool import _find_all_skills
|
from tools.skills_tool import _find_all_skills
|
||||||
|
|
||||||
c = console or _console
|
c = console or _console
|
||||||
|
ensure_hub_dirs()
|
||||||
lock = HubLockFile()
|
lock = HubLockFile()
|
||||||
hub_installed = {e["name"]: e for e in lock.list_installed()}
|
hub_installed = {e["name"]: e for e in lock.list_installed()}
|
||||||
|
|
||||||
|
|
|
||||||
31
tests/hermes_cli/test_skills_hub.py
Normal file
31
tests/hermes_cli/test_skills_hub.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
|
from hermes_cli.skills_hub import do_list
|
||||||
|
|
||||||
|
|
||||||
|
def test_do_list_initializes_hub_dir(monkeypatch, tmp_path):
|
||||||
|
import tools.skills_hub as hub
|
||||||
|
import tools.skills_tool as skills_tool
|
||||||
|
|
||||||
|
hub_dir = tmp_path / "skills" / ".hub"
|
||||||
|
monkeypatch.setattr(hub, "SKILLS_DIR", tmp_path / "skills")
|
||||||
|
monkeypatch.setattr(hub, "HUB_DIR", hub_dir)
|
||||||
|
monkeypatch.setattr(hub, "LOCK_FILE", hub_dir / "lock.json")
|
||||||
|
monkeypatch.setattr(hub, "QUARANTINE_DIR", hub_dir / "quarantine")
|
||||||
|
monkeypatch.setattr(hub, "AUDIT_LOG", hub_dir / "audit.log")
|
||||||
|
monkeypatch.setattr(hub, "TAPS_FILE", hub_dir / "taps.json")
|
||||||
|
monkeypatch.setattr(hub, "INDEX_CACHE_DIR", hub_dir / "index-cache")
|
||||||
|
monkeypatch.setattr(skills_tool, "_find_all_skills", lambda: [])
|
||||||
|
|
||||||
|
console = Console(file=StringIO(), force_terminal=False, color_system=None)
|
||||||
|
|
||||||
|
assert not hub_dir.exists()
|
||||||
|
|
||||||
|
do_list(console=console)
|
||||||
|
|
||||||
|
assert hub_dir.exists()
|
||||||
|
assert (hub_dir / "lock.json").exists()
|
||||||
|
assert (hub_dir / "quarantine").is_dir()
|
||||||
|
assert (hub_dir / "index-cache").is_dir()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue