The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(onboarding): the build beat names a plugin skill by its registered name
alt-glitcha38e566bcb74
diff --git a/agent/onboarding_first_tasks.py b/agent/onboarding_first_tasks.pyindex 389195036f9..19be083d312 100644--- a/agent/onboarding_first_tasks.py+++ b/agent/onboarding_first_tasks.py@@ -25,8 +25,8 @@ OWN_ID = "own"@dataclass(frozen=True)class FirstTask:"""``skills`` load first, before the work; an entry ``a|b`` means one of them, whichever fits.- Plugin skills use the ``<plugin>:<skill>`` form skill_view resolves. ``goal`` finishes the- sentence "Your job: ..."."""+ A plugin skill is written ``<catalog plugin>:<skill>``; :func:`task_skills` names it by the name it+ registered under on this install. ``goal`` finishes the sentence "Your job: ..."."""id: strlabel: str@@ -304,13 +304,14 @@ def pick_error(options: Any, facts: Facts, picks: Mapping[str, Any]) -> str | Nof"{MAX_PICKS} of these ids: {', '.join(eligible)}.")-def task_skills(option: str, has_skill: Callable[[str], bool]) -> list[str]:- """The skills a task loads first, humanizer last. A bundled skill missing here is dropped; a plugin- skill (``plugin:skill``) is kept, since the plugin being installed is the row's gate."""+def task_skills(option: str, resolve_skill: Callable[[str], str | None]) -> list[str]:+ """The skills a task loads first, humanizer last, each by the name ``skill_view`` loads it with here:+ ``resolve_skill`` maps a written name to that name (a plugin skill's registered name differs from+ its ``<plugin>:<skill>`` form), or to None for a skill missing here, which is dropped."""names = [*TASK_BY_ID.get(option, OWN_TASK).skills, EVERY_TASK_SKILL]kept = []for entry in names:- found = [name for name in entry.split("|") if ":" in name or has_skill(name)]+ found = [resolved for name in entry.split("|") if (resolved := resolve_skill(name))]if found:kept.append(" or ".join(found))return keptdiff --git a/agent/onboarding_text.py b/agent/onboarding_text.pyindex 164cd4a2095..ecb5053b571 100644--- a/agent/onboarding_text.py+++ b/agent/onboarding_text.py@@ -183,12 +183,12 @@ _SPARK_LINE = "This machine is built for local models; say so once when it fits_REMOTE_LINE = "Hermes runs on another computer than the user's: say which machine anything is installed on."-def _task_prompt(option: str, label: str, has_skill: Callable[[str], bool]) -> list[str]:+def _task_prompt(option: str, label: str, resolve_skill: Callable[[str], str | None]) -> list[str]:task = TASK_BY_ID.get(option, OWN_TASK)picked = f'They picked "{label or task.label}". ' if (label or task.label) else ""steps = [f"{n}. {step}" for n, step in enumerate(task.steps, 1)]return [f"{picked}Your job: {task.goal}.",- f"Load these skills with skill_view first: {', '.join(task_skills(option, has_skill))}.",+ f"Load these skills with skill_view first: {', '.join(task_skills(option, resolve_skill))}.","Steps:", *steps, f"Output: {task.output}", f"Quality bar: {task.quality}", f"Done when: {task.done}"]@@ -196,10 +196,10 @@ def _bullets(title: str, lines) -> str:return "\n".join([f"{title}:", *(f"- {line}" for line in lines)])-def build_guidance(option: str, facts: Facts, has_skill: Callable[[str], bool] = lambda name: True,+def build_guidance(option: str, facts: Facts, resolve_skill: Callable[[str], str | None] = lambda name: name,label: str = "") -> str:- """The prompt once a first task is picked; ``label`` is the card text they clicked, ``has_skill``- says whether a bundled skill is on this install."""+ """The prompt once a first task is picked; ``label`` is the card text they clicked, ``resolve_skill``+ names a skill as this install loads it (None: missing here)."""work = [*_HOW_TO_WORK, _preview_line(facts), *((_CONNECTORS,) if option in _CONNECTOR_TASKS else ())]page = [_bullets("When you make a page", _PAGE)] if option in _PAGE_TASKS else []host = [_OS_LINES.get(facts.os, _OS_LINES["linux"])]@@ -209,7 +209,7 @@ def build_guidance(option: str, facts: Facts, has_skill: Callable[[str], bool] =host.append(_SPARK_LINE)if facts.facts_source == "remote":host.append(_REMOTE_LINE)- return "\n\n".join(["\n".join(_task_prompt(option, label, has_skill)), _bullets("How to work", work), *page,+ return "\n\n".join(["\n".join(_task_prompt(option, label, resolve_skill)), _bullets("How to work", work), *page,_bullets("This computer", host), f"When it is shown:\n{_CLOSE}"])@@ -305,9 +305,9 @@ def _timed_out(record, facts, beat: str) -> str:def reminder(key: str, record: Mapping[str, Any], facts: Facts, beat: str | None = None,- has_skill: Callable[[str], bool] = lambda name: True) -> str:+ resolve_skill: Callable[[str], str | None] = lambda name: name) -> str:"""The text for a reminder key; ``beat`` names the card a ``wrote`` / ``timed_out`` result is about;- ``has_skill`` drops a first task's bundled skill missing on this install."""+ ``resolve_skill`` names a first task's skill as this install loads it, None dropping a missing one."""if not key:return ""if key in ("wrote", "timed_out"):@@ -315,7 +315,7 @@ def reminder(key: str, record: Mapping[str, Any], facts: Facts, beat: str | Noneif key.startswith("build_"):option = key.removeprefix("build_")label = next((o["label"] for o in record["picks"].get("build_options") or () if o["id"] == option), "")- return build_guidance(option, facts, has_skill, label)+ return build_guidance(option, facts, resolve_skill, label)if key.startswith("already_"):return _already(record, key.removeprefix("already_"))return _REMINDERS[key](record, facts)diff --git a/hermes_cli/plugins_activation_live.py b/hermes_cli/plugins_activation_live.pyindex aa8c17cff62..1b854f65399 100644--- a/hermes_cli/plugins_activation_live.py+++ b/hermes_cli/plugins_activation_live.py@@ -13,6 +13,7 @@ live session leaves the model-facing tool array (and the cached prompt prefix) bfrom __future__ import annotationsimport logging+from pathlib import Pathfrom typing import Any, Dict, List, Optionallogger = logging.getLogger(__name__)@@ -83,6 +84,25 @@ def plugin_skills(plugin_key: str) -> list[dict[str, str]]:for qualified, entry in sorted(skills.items()) if entry.get("plugin_key") == plugin_key]+def catalog_plugin_skill(written: str) -> Optional[str]:+ """The registered name of a plugin skill written ``<catalog-name>:<skill>`` (``blender:blender``), or+ None when that catalog plugin is not installed in this profile or registered no such skill. A+ portable plugin's skills register under a collision-resistant namespace+ (``agent-plugin-<slug>-<sha8>:<skill>``, ``hermes_cli/plugins_manifest.py``), so the readable form+ is never itself a name ``skill_view`` resolves."""+ from hermes_cli.plugins import get_plugin_manager+ from hermes_cli.plugins_cmd import _catalog_installed_dir+ catalog_name, _, bare = written.partition(":")+ target = _catalog_installed_dir(catalog_name)+ if target is None:+ return None+ manager = get_plugin_manager()+ keys = {key for key, loaded in manager._plugins.items()+ if loaded.manifest.path and Path(loaded.manifest.path).resolve() == target.resolve()}+ return next((qualified for qualified, entry in sorted(manager._plugin_skills.items())+ if entry.get("plugin_key") in keys and entry.get("bare_name") == bare), None)++def live_notice(activation: dict[str, Any]) -> str:"""The note an open chat gets on its next tool result or turn (``agent/plugin_live_notes.py``): theplugin's skills and, per MCP server, its tool prefix and count or why it did not connect. Tools arediff --git a/tests/agent/test_onboarding_first_tasks.py b/tests/agent/test_onboarding_first_tasks.pyindex cb72ae36d5c..cf232d4ccaa 100644--- a/tests/agent/test_onboarding_first_tasks.py+++ b/tests/agent/test_onboarding_first_tasks.py@@ -36,15 +36,16 @@ def test_brief_and_week_need_an_app_connected_this_run_and_mac_helpers_need_macodef test_a_task_reminder_opens_with_its_skills_and_drops_a_bundled_skill_this_install_lacks():- text = reminder("build_explain", new_record(MAC), MAC, has_skill=lambda name: name != "p5js")+ text = reminder("build_explain", new_record(MAC), MAC, resolve_skill=lambda name: None if name == "p5js" else name)goal, skills = text.split("\n")[:2]assert goal.startswith('They picked "Explain a topic I care about". Your job: ')assert skills == ("Load these skills with skill_view first: grounded-citations, claude-design, ""blocked-page-recovery, humanizer.")- # Plugin skills come with the plugin, which is the row's gate; a typed task starts from hermes-agent.- assert reminder("build_games", new_record(PC), PC, has_skill=lambda name: False).split("\n")[1] == (- "Load these skills with skill_view first: nvidia-app:nvidia-app.")+ # A plugin skill is named as it registered; a typed task starts from hermes-agent.+ registered = {"nvidia-app:nvidia-app": "agent-plugin-nvidia-app-f9a26bc6:nvidia-app"}+ assert reminder("build_games", new_record(PC), PC, resolve_skill=registered.get).split("\n")[1] == (+ "Load these skills with skill_view first: agent-plugin-nvidia-app-f9a26bc6:nvidia-app.")assert reminder("build_own", new_record(MAC), MAC).split("\n")[:2] == ["Your job: build the task they named in their own words.","Load these skills with skill_view first: hermes-agent, humanizer."]diff --git a/tests/tools/test_setup_beat_plugin_skills.py b/tests/tools/test_setup_beat_plugin_skills.pynew file mode 100644index 00000000000..30b5cb0a555--- /dev/null+++ b/tests/tools/test_setup_beat_plugin_skills.py@@ -0,0 +1,73 @@+"""The build beat names a plugin's skill by the name it registered under.++A first task writes a plugin skill readably (``blender:blender``), but a portable plugin's skills+register under a collision-resistant namespace (``agent-plugin-blender-<sha8>:blender``). In a live run+the build beat sent the readable form, ``skill_view("blender:blender")`` missed, and the model rendered+headless without the skill. Real plugin discovery against a temp ``HERMES_HOME``.+"""++from __future__ import annotations++import json++import pytest++from agent import onboarding_flow as flow+from hermes_cli import plugins as plugins_mod+from tools.setup_beat_tool import _result++PC = flow.Facts(os="windows", arch="amd64", machine_kind="PC", nvidia_platform="discrete")+++def home(tmp_path, monkeypatch):+ home = tmp_path / ".hermes"+ (home / "plugins").mkdir(parents=True)+ (home / "config.yaml").write_text(json.dumps({"plugins": {"enabled": ["blender"]}}))+ bundled = tmp_path / "bundled"+ bundled.mkdir()+ monkeypatch.setenv("HERMES_HOME", str(home))+ monkeypatch.setattr(plugins_mod, "get_bundled_plugins_dir", lambda: bundled)+ plugins_mod._reset_plugin_managers_for_tests()+ yield home+ plugins_mod._reset_plugin_managers_for_tests()+++def _install_blender_from_catalog(home):+ """What a catalog install leaves: the portable plugin tree and the installer-owned record."""+ from hermes_cli.agent_plugins import PLUGIN_SCHEMA_V1++ plugin = home / "plugins" / "blender"+ (plugin / "skills" / "blender").mkdir(parents=True)+ (plugin / "plugin.json").write_text(json.dumps({"$schema": PLUGIN_SCHEMA_V1, "name": "blender"}))+ (plugin / "skills" / "blender" / "SKILL.md").write_text(+ "---\nname: blender\ndescription: Drive Blender.\n---\nBody.\n")+ (home / "plugins" / ".install-metadata.json").write_text(json.dumps({"blender": {+ "source": "https://example.com/blender.git",+ "catalog": {"name": "blender", "repo": "https://example.com/blender.git", "sha": "0" * 40}}}))+++def _build_skills_line() -> str:+ record = flow.new_record(PC)+ record["picks"]["installed"] = ["blender"]+ reminder = json.loads(_result(flow.Step(record=record, result={}, reminder="build_blender")))["reminder"]+ return next(line for line in reminder.split("\n") if line.startswith("Load these skills"))+++def test_the_build_beat_names_an_installed_plugin_skill_by_its_registered_name(home):+ _install_blender_from_catalog(home)+ manager = plugins_mod.get_plugin_manager()+ manager.discover_and_load(force=True)+ [registered] = [skill["name"] for skill in manager.list_plugin_skill_metadata()]+ assert registered.startswith("agent-plugin-blender-") and registered.endswith(":blender")++ line = _build_skills_line()++ assert registered in line+ assert "blender:blender" not in line.replace(registered, "")+++def test_a_plugin_skill_that_is_not_installed_is_dropped(home):+ plugins_mod.get_plugin_manager().discover_and_load(force=True)++ assert "blender" not in _build_skills_line()diff --git a/tools/setup_beat_tool.py b/tools/setup_beat_tool.pyindex ee7a0eee98d..8b6e21cdbe3 100644--- a/tools/setup_beat_tool.py+++ b/tools/setup_beat_tool.py@@ -74,17 +74,21 @@ def _reply_event(beat: str, reply: Mapping[str, Any] | None) -> flow.Event:return flow.Answered(beat, answer) if isinstance(answer, dict) and answer else flow.TimedOut(beat, _present(beat))-def _installed_skills() -> Callable[[str], bool]:+def _skill_resolver() -> Callable[[str], str | None]:+ """A written first-task skill name -> the name skill_view loads it with here, or None. A plugin skill+ (``blender:blender``) resolves through the installed catalog plugin to its registered name."""+ from hermes_cli.plugins_activation_live import catalog_plugin_skillfrom tools.skills_tool import _find_all_skills- return {skill["name"] for skill in _find_all_skills()}.__contains__+ bundled = {skill["name"] for skill in _find_all_skills()}+ return lambda name: catalog_plugin_skill(name) if ":" in name else (name if name in bundled else None)def _result(step: flow.Step, beat: str | None = None) -> str:facts = flow.Facts.from_stored(step.record["facts"])# Only a first task's reminder names skills; the skills scan is skipped for every other result.- has_skill = _installed_skills() if step.reminder.startswith("build_") else (lambda name: True)- text = reminder(step.reminder, step.record, facts, beat, has_skill)+ resolve_skill = _skill_resolver() if step.reminder.startswith("build_") else (lambda name: name)+ text = reminder(step.reminder, step.record, facts, beat, resolve_skill)return json.dumps({**step.result, **({"reminder": text} if text else {})}, ensure_ascii=False)