mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
Subcommands whose handler was a closure defined inside main() — memory, acp, tools, insights, skills, pairing, plugins, mcp, claw — have their handler promoted to a top-level function and their parser block extracted into hermes_cli/subcommands/<name>.py (build_<name>_parser, injected handler). These 9 had zero closure-over-main-locals, so promotion is a pure relocation. acp/mcp parser blocks use the shared add_accept_hooks_flag helper. main() 1798 -> 954 LOC (71% below the 3297 Phase-2 starting point); add_parser calls in main.py 89 -> 28. Deferred: sessions, computer-use, secrets handlers reference <name>_parser (for a no-subcommand print_help fallback) — left in place to avoid the _self_parser indirection; minority, low value. Behavior-neutral: all 9 subcommands' --help (incl nested subactions) byte- identical to pre-extraction (diff-verified). tests/hermes_cli/ 6519 passed / 0 failed; new test_subcommands_followup.py covers the 9 builders.
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""``hermes memory`` subcommand parser.
|
|
|
|
Extracted from ``hermes_cli/main.py:main()`` (god-file Phase 2 follow-up).
|
|
Handler injected to avoid importing ``main``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Callable
|
|
|
|
|
|
def build_memory_parser(subparsers, *, cmd_memory: Callable) -> None:
|
|
"""Attach the ``memory`` subcommand to ``subparsers``."""
|
|
memory_parser = subparsers.add_parser(
|
|
"memory",
|
|
help="Configure external memory provider",
|
|
description=(
|
|
"Set up and manage external memory provider plugins.\n\n"
|
|
"Available providers: honcho, openviking, mem0, hindsight,\n"
|
|
"holographic, retaindb, byterover.\n\n"
|
|
"Only one external provider can be active at a time.\n"
|
|
"Built-in memory (MEMORY.md/USER.md) is always active."
|
|
),
|
|
)
|
|
memory_sub = memory_parser.add_subparsers(dest="memory_command")
|
|
_setup_parser = memory_sub.add_parser(
|
|
"setup", help="Interactive provider selection and configuration"
|
|
)
|
|
_setup_parser.add_argument(
|
|
"provider",
|
|
nargs="?",
|
|
default=None,
|
|
help="Provider to configure directly (e.g. honcho), skipping the picker",
|
|
)
|
|
memory_sub.add_parser("status", help="Show current memory provider config")
|
|
memory_sub.add_parser("off", help="Disable external provider (built-in only)")
|
|
_reset_parser = memory_sub.add_parser(
|
|
"reset",
|
|
help="Erase all built-in memory (MEMORY.md and USER.md)",
|
|
)
|
|
_reset_parser.add_argument(
|
|
"--yes",
|
|
"-y",
|
|
action="store_true",
|
|
help="Skip confirmation prompt",
|
|
)
|
|
_reset_parser.add_argument(
|
|
"--target",
|
|
choices=["all", "memory", "user"],
|
|
default="all",
|
|
help="Which store to reset: 'all' (default), 'memory', or 'user'",
|
|
)
|
|
memory_parser.set_defaults(func=cmd_memory)
|