The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: setup's agent-import question shows what was found; imports run as part of setup
Tekniumc2e31263cb53
diff --git a/hermes_cli/setup.py b/hermes_cli/setup.pyindex 43990ff1eac..53bc84432c6 100644--- a/hermes_cli/setup.py+++ b/hermes_cli/setup.py@@ -284,15 +284,17 @@ def is_noninteractive() -> bool:return os.environ.get("HERMES_NONINTERACTIVE", "").strip().lower() in {"1", "true", "yes", "on"}-def prompt_yes_no(question: str, default: bool = True) -> bool:+def prompt_yes_no(question: str, default: bool = True, description: str | None = None) -> bool:"""Prompt for yes/no. Ctrl+C exits; empty input, ``HERMES_NONINTERACTIVE=1`` or a- closed/redirected stdin return ``default`` instead of aborting the whole process."""+ closed/redirected stdin return ``default`` instead of aborting the whole process.+ ``description`` is the context the question refers to, shown above it in setup's full-screen+ menu, which hides everything printed before it; the line prompt keeps that text on screen."""if is_noninteractive():return default# Inside setup, route binary selections through the curses menu so ESC and left-arrow work# consistently; every other caller keeps the traditional line prompt.if _SETUP_NAVIGATION.get() is not None:- return _curses_prompt_choice(question, ["Yes", "No"], 0 if default else 1) == 0+ return _curses_prompt_choice(question, ["Yes", "No"], 0 if default else 1, description=description) == 0default_str = "Y/n" if default else "y/N"while True:try:diff --git a/hermes_cli/setup_agent_import.py b/hermes_cli/setup_agent_import.pyindex 8b22be11335..55006eecea2 100644--- a/hermes_cli/setup_agent_import.py+++ b/hermes_cli/setup_agent_import.py@@ -13,6 +13,7 @@ from __future__ import annotationsimport osimport subprocessimport sys+import textwrapfrom pathlib import Pathfrom typing import NamedTuple, Optional@@ -58,12 +59,15 @@ def offer_agent_import(hermes_home: Path) -> str:return ""user_home = str(Path.home())print_header("Coming from another agent?", gap=True)- _info("Found on this computer: " + ", ".join(+ context = ("Found on this computer: " + ", ".join(f"{s.label} ({str(p).replace(user_home, '~', 1)})" for s, p in found) + ".","Hermes can bring over its settings, memories, skills and MCP servers.","You'll see a preview and confirm before anything changes.")+ _info(*context)names = " or ".join(s.label for s, _ in found) if len(found) <= 2 else "any of them"- if not prompt_yes_no(f"Import your setup from {names}?", default=True):+ # The menu clears the screen, so the question carries what it refers to ("any of them").+ if not prompt_yes_no(f"Import your setup from {names}?", default=True,+ description="\n".join(f" {w}" for line in context for w in textwrap.wrap(line, 76))):print_info(f"Skipped. Import later with: hermes plugins install {PLUGIN}, then hermes import-agent")return ""picked = _pick_sources(found)@@ -100,7 +104,7 @@ def _ensure_plugin(hermes_home: Path) -> bool:if present:cmd_enable(PLUGIN)else:- cmd_install(PLUGIN, enable=True)+ cmd_install(PLUGIN, enable=True, brief=True) # the line above already said what and why# Both print their own error first: a refusal exits, an enable whose dependencies PM cannot# admit raises. Either way the import is skipped and the rest of setup goes on.except (SystemExit, AdmissionRefused):@@ -130,13 +134,16 @@ def _run_import(source: ImportSource, hermes_home: Path) -> bool:# A home that is not <root>/profiles/<name> is the root: without a selector the child's# _apply_profile_override would follow the sticky active_profile into another profile.selector = [] if hermes_home.resolve().parent.name == "profiles" else ["--profile", "default"]- argv = [sys.executable, "-m", "hermes_cli.main", *selector, "import-agent", source.name, *source.extra_args]+ # --from-setup: the plugin's import speaks as a step of this setup (no "run hermes setup" pointers,+ # OpenClaw's skipped items folded into one line).+ argv = [sys.executable, "-m", "hermes_cli.main", *selector, "import-agent", source.name, *source.extra_args,+ "--from-setup"]env = served_profile_child_env(target_home=hermes_home)if os.environ.get("PYTHONPATH"): # this same interpreter running Hermes: keep the source treeenv["PYTHONPATH"] = os.environ["PYTHONPATH"] # a checkout launched by path, which it strips# health: allow HX006 -- interactive child: the user reads its preview and answers its promptsif subprocess.run(argv, env=env, check=False).returncode:- # An install from before the plugin gained this importer refuses the name (argparse, exit 2).- print_warning(f"The {source.label} import did not run. If the error names an invalid choice, "- f"update the plugin first: hermes plugins update {PLUGIN}")+ # An install from before the plugin gained this importer, or --from-setup, refuses it (argparse, exit 2).+ print_warning(f"The {source.label} import did not run. If the error names an invalid choice or "+ f"unrecognized arguments, update the plugin first: hermes plugins update {PLUGIN}")return _snapshot(hermes_home) != beforediff --git a/tests/hermes_cli/test_setup_agent_import.py b/tests/hermes_cli/test_setup_agent_import.pyindex 32ba3ce4f48..9268938ce0c 100644--- a/tests/hermes_cli/test_setup_agent_import.py+++ b/tests/hermes_cli/test_setup_agent_import.py@@ -13,6 +13,7 @@ import subprocessimport pytestfrom hermes_cli import setup_agent_import as step+from hermes_cli.setup import prompt_yes_no as real_prompt_yes_no@pytest.fixture@@ -26,7 +27,7 @@ def homes(tmp_path, monkeypatch):calls: list = []answers = {"yes": True, "unpick": set()}- def ask(question, default=True):+ def ask(question, default=True, description=None):calls.append(("ask", question, default))return answers["yes"]@@ -34,8 +35,8 @@ def homes(tmp_path, monkeypatch):calls.append(("pick", list(items), list(pre_selected)))return [i for i in pre_selected if items[i] not in answers["unpick"]]- def install(name, enable=None, **_):- calls.append(("install", name, enable))+ def install(name, enable=None, brief=False, **_):+ calls.append(("install", name, enable, brief))(hermes_home / "plugins" / name).mkdir(parents=True)def run(argv, env, check=False):@@ -59,10 +60,12 @@ def test_found_agent_is_offered_then_installed_from_the_catalog_and_imported(homassert calls == [("ask", "Import your setup from OpenClaw?", True),- ("install", "agent-importers", True),+ ("install", "agent-importers", True, True),# core's setup migrated OpenClaw's allowlisted secrets after the preview; so does this step.# The root home is named explicitly, so a sticky active_profile cannot redirect the child.- ("import", ["--profile", "default", "import-agent", "openclaw", "--migrate-secrets"], str(hermes_home)),+ # --from-setup: the plugin words its preview and result as a step of this setup.+ ("import", ["--profile", "default", "import-agent", "openclaw", "--migrate-secrets", "--from-setup"],+ str(hermes_home)),]@@ -75,8 +78,9 @@ def test_several_found_are_offered_as_a_checklist_and_only_the_picks_import(homeassert step.offer_agent_import(hermes_home) == "Claude Code"assert calls[1] == ("pick", ["Claude Code", "Cursor"], [0, 1]) # never an agent that is absent- assert calls[2:] == [("install", "agent-importers", True),- ("import", ["--profile", "default", "import-agent", "claude-code"], str(hermes_home))]+ assert calls[2:] == [("install", "agent-importers", True, True),+ ("import", ["--profile", "default", "import-agent", "claude-code", "--from-setup"],+ str(hermes_home))]def test_declining_installs_nothing(homes):@@ -119,3 +123,28 @@ def test_a_refused_enable_skips_the_import_and_setup_goes_on(homes, monkeypatch)assert step.offer_agent_import(hermes_home) == ""assert calls == [("ask", "Import your setup from Cursor?", True), ("enable", "agent-importers")]+++def test_setup_menu_shows_what_was_found_with_the_question(homes, monkeypatch):+ """Setup's yes/no is a full-screen menu that hides what was printed before it, so the detection+ lines travel with the question: "any of them" must point at text the user can see."""+ from hermes_cli import setup+ user_home, hermes_home, calls, _answers = homes+ for d in (".openclaw", ".claude", ".codex"):+ (user_home / d).mkdir()+ menus = []++ def radiolist(title, items, selected=0, *, description=None, **_):+ menus.append((title, items, description))+ return 1 # "No"+ monkeypatch.setattr("hermes_cli.setup.prompt_yes_no", real_prompt_yes_no)+ monkeypatch.setattr("hermes_cli.curses_ui.curses_radiolist", radiolist)++ with setup._setup_navigation_scope():+ assert step.offer_agent_import(hermes_home) == ""++ [(title, items, description)] = menus+ assert (title, items) == ("Import your setup from any of them?", ["Yes", "No"])+ assert ("Found on this computer: OpenClaw (~/.openclaw), Claude Code (~/.claude), Codex CLI (~/.codex)."+ in " ".join(description.split()))+ assert calls == [] and not (hermes_home / "plugins").exists()