From 89eab74c677ca3817ec3244ccaabdf67f8affdb9 Mon Sep 17 00:00:00 2001 From: Erosika Date: Mon, 30 Mar 2026 16:52:45 -0400 Subject: [PATCH] feat(honcho): --target-profile flag + peer card display in status - hermes honcho --target-profile : target another profile's Honcho config without switching profiles. Works with all subcommands (status, peer, mode, tokens, enable, disable, etc.) - hermes honcho status now shows user peer card and AI peer representation when connected (fetched live from Honcho API) --- hermes_cli/main.py | 4 +++ honcho_integration/cli.py | 53 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 1eb77572b..933de9154 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -4519,6 +4519,10 @@ For more help on a command: ), formatter_class=__import__("argparse").RawDescriptionHelpFormatter, ) + honcho_parser.add_argument( + "--target-profile", metavar="NAME", dest="target_profile", + help="Target a specific profile's Honcho config without switching", + ) honcho_subparsers = honcho_parser.add_subparsers(dest="honcho_command") honcho_subparsers.add_parser("setup", help="Interactive setup wizard for Honcho integration") diff --git a/honcho_integration/cli.py b/honcho_integration/cli.py index 2bd74c73b..4945bbb04 100644 --- a/honcho_integration/cli.py +++ b/honcho_integration/cli.py @@ -144,8 +144,15 @@ def cmd_disable(args) -> None: print(f" Saved to {_config_path()}\n") +_profile_override: str | None = None + + def _host_key() -> str: """Return the active Honcho host key, derived from the current Hermes profile.""" + if _profile_override: + if _profile_override in ("default", "custom"): + return HOST + return f"{HOST}.{_profile_override}" return resolve_active_host() @@ -371,7 +378,9 @@ def cmd_setup(args) -> None: def _active_profile_name() -> str: - """Return the active Hermes profile name.""" + """Return the active Hermes profile name (respects --target-profile override).""" + if _profile_override: + return _profile_override try: from hermes_cli.profiles import get_active_profile_name return get_active_profile_name() @@ -469,8 +478,9 @@ def cmd_status(args) -> None: if hcfg.enabled and (hcfg.api_key or hcfg.base_url): print("\n Connection... ", end="", flush=True) try: - get_honcho_client(hcfg) - print("OK\n") + client = get_honcho_client(hcfg) + print("OK") + _show_peer_cards(hcfg, client) except Exception as e: print(f"FAILED ({e})\n") else: @@ -478,6 +488,40 @@ def cmd_status(args) -> None: print(f"\n Not connected ({reason})\n") +def _show_peer_cards(hcfg, client) -> None: + """Fetch and display peer cards for the active profile.""" + try: + from honcho_integration.session import HonchoSessionManager + mgr = HonchoSessionManager(honcho=client, config=hcfg) + session_key = hcfg.resolve_session_name() + session = mgr.get_or_create(session_key) + + # User peer card + card = mgr.get_peer_card(session_key) + if card: + print(f"\n User peer card ({len(card)} facts):") + for fact in card[:10]: + print(f" - {fact}") + if len(card) > 10: + print(f" ... and {len(card) - 10} more") + + # AI peer representation + ai_rep = mgr.get_ai_representation(session_key) + ai_text = ai_rep.get("representation", "") + if ai_text: + # Truncate to first 200 chars + display = ai_text[:200] + ("..." if len(ai_text) > 200 else "") + print(f"\n AI peer representation:") + print(f" {display}") + + if not card and not ai_text: + print("\n No peer data yet (accumulates after first conversation)") + + print() + except Exception as e: + print(f"\n Peer data unavailable: {e}\n") + + def _cmd_status_all() -> None: """Show Honcho config overview across all profiles.""" rows = _all_profile_host_configs() @@ -1004,6 +1048,9 @@ def cmd_migrate(args) -> None: def honcho_command(args) -> None: """Route honcho subcommands.""" + global _profile_override + _profile_override = getattr(args, "target_profile", None) + sub = getattr(args, "honcho_command", None) if sub == "setup" or sub is None: cmd_setup(args)