mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-01 07:01:41 +00:00
fix(skills-hub): widen identifier-dedup to GitHubSource + fix test patch path
Sibling fix on top of @EloquentBrush0x's PR #29441. - tools/skills_hub.py GitHubSource.search() had the same r.name dedup bug. Two configured GitHub taps publishing same-named skills would collapse to one. - tests/hermes_cli/test_skills_hub.py:test_browse_skills_dedup_uses_identifier_not_name patched hermes_cli.skills_hub.create_source_router, but browse_skills() imports it locally from tools.skills_hub. Fixed patch path.
This commit is contained in:
parent
8f92327891
commit
c6a380eb6c
2 changed files with 10 additions and 6 deletions
|
|
@ -555,7 +555,9 @@ def test_browse_skills_dedup_uses_identifier_not_name(monkeypatch):
|
|||
"search": lambda self, q, limit=500: [airbnb, booking],
|
||||
})()
|
||||
|
||||
with patch("hermes_cli.skills_hub.create_source_router", return_value=[mock_src]):
|
||||
# browse_skills() imports create_source_router locally from tools.skills_hub,
|
||||
# so the patch must target the source module, not hermes_cli.skills_hub.
|
||||
with patch("tools.skills_hub.create_source_router", return_value=[mock_src]):
|
||||
result = browse_skills(page=1, page_size=50)
|
||||
|
||||
names = [item["name"] for item in result["items"]]
|
||||
|
|
|
|||
|
|
@ -379,14 +379,16 @@ class GitHubSource(SkillSource):
|
|||
logger.debug(f"Failed to search {tap['repo']}: {e}")
|
||||
continue
|
||||
|
||||
# Deduplicate by name, preferring higher trust levels
|
||||
# Deduplicate by identifier, preferring higher trust levels.
|
||||
# identifier is unique per skill; name is not (two configured taps can
|
||||
# publish skills with the same name but different identifiers).
|
||||
_trust_rank = {"builtin": 2, "trusted": 1, "community": 0}
|
||||
seen = {}
|
||||
for r in results:
|
||||
if r.name not in seen:
|
||||
seen[r.name] = r
|
||||
elif _trust_rank.get(r.trust_level, 0) > _trust_rank.get(seen[r.name].trust_level, 0):
|
||||
seen[r.name] = r
|
||||
if r.identifier not in seen:
|
||||
seen[r.identifier] = r
|
||||
elif _trust_rank.get(r.trust_level, 0) > _trust_rank.get(seen[r.identifier].trust_level, 0):
|
||||
seen[r.identifier] = r
|
||||
results = list(seen.values())
|
||||
|
||||
return results[:limit]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue