refactor(hermes_cli): setup cluster — extract _prompt_session_reset, template migration summary lines
This commit is contained in:
@@ -503,19 +503,20 @@ def setup_agent_settings(config: dict):
|
||||
# ── Session Reset Policy ──
|
||||
print_header("Session Reset Policy")
|
||||
_info(*_SESSION_RESET_HELP)
|
||||
_prompt_session_reset(config.setdefault("session_reset", {}))
|
||||
save_config(config)
|
||||
|
||||
current_policy = config.get("session_reset", {})
|
||||
current_mode = current_policy.get("mode", "none")
|
||||
current_idle = current_policy.get("idle_minutes", 1440)
|
||||
current_hour = current_policy.get("at_hour", 4)
|
||||
|
||||
def _prompt_session_reset(reset_cfg: dict) -> None:
|
||||
"""Pick the session reset mode and its idle/daily parameters in place."""
|
||||
current_mode = reset_cfg.get("mode", "none")
|
||||
current_idle, current_hour = reset_cfg.get("idle_minutes", 1440), reset_cfg.get("at_hour", 4)
|
||||
default_reset = _SESSION_RESET_MODES.index(current_mode) if current_mode in _SESSION_RESET_MODES else 3
|
||||
reset_idx = prompt_choice("Session reset mode:", _SESSION_RESET_CHOICES, default_reset)
|
||||
|
||||
reset_cfg = config.setdefault("session_reset", {})
|
||||
mode = _SESSION_RESET_MODES[reset_idx] if 0 <= reset_idx < len(_SESSION_RESET_MODES) else None
|
||||
if mode is not None:
|
||||
reset_cfg["mode"] = mode
|
||||
if mode is None: # keep current settings
|
||||
return
|
||||
reset_cfg["mode"] = mode
|
||||
if mode in ("both", "idle"):
|
||||
_prompt_int_setting(reset_cfg, "idle_minutes", " Inactivity timeout (minutes)", current_idle, lambda v: v > 0)
|
||||
if mode in ("both", "daily"):
|
||||
@@ -524,15 +525,13 @@ def setup_agent_settings(config: dict):
|
||||
if mode == "none":
|
||||
print_info("Sessions will never auto-reset. Context is managed only by compression.")
|
||||
print_warning("Long conversations will grow in cost. Use /reset manually when needed.")
|
||||
elif mode is not None:
|
||||
else:
|
||||
print_success({
|
||||
"both": f"Sessions reset after {idle_now} min idle or daily at {hour_now}:00",
|
||||
"idle": f"Sessions reset after {idle_now} min of inactivity",
|
||||
"daily": f"Sessions reset daily at {hour_now}:00",
|
||||
}[mode])
|
||||
|
||||
save_config(config)
|
||||
|
||||
|
||||
# ── Section 5: Tool Configuration (delegates to unified tools_config.py) ──
|
||||
|
||||
|
||||
@@ -315,18 +315,17 @@ def _offer_openclaw_migration(hermes_home: Path) -> bool:
|
||||
return False
|
||||
|
||||
summary = report.get("summary", {})
|
||||
migrated, skipped = summary.get("migrated", 0), summary.get("skipped", 0)
|
||||
conflicts, errors = summary.get("conflict", 0), summary.get("error", 0)
|
||||
print()
|
||||
for count, printer, text in (
|
||||
(migrated, print_success, f"Imported {migrated} item(s) from OpenClaw."),
|
||||
(conflicts, print_info,
|
||||
f"Skipped {conflicts} item(s) that already exist in Hermes (use hermes claw migrate --overwrite to force)."),
|
||||
(skipped, print_info, f"Skipped {skipped} item(s) (not found or unchanged)."),
|
||||
(errors, print_warning, f"{errors} item(s) had errors — check the migration report."),
|
||||
for key, printer, text in (
|
||||
("migrated", print_success, "Imported {n} item(s) from OpenClaw."),
|
||||
("conflict", print_info,
|
||||
"Skipped {n} item(s) that already exist in Hermes (use hermes claw migrate --overwrite to force)."),
|
||||
("skipped", print_info, "Skipped {n} item(s) (not found or unchanged)."),
|
||||
("error", print_warning, "{n} item(s) had errors — check the migration report."),
|
||||
):
|
||||
count = summary.get(key, 0)
|
||||
if count:
|
||||
printer(text)
|
||||
printer(text.format(n=count))
|
||||
|
||||
output_dir = report.get("output_dir")
|
||||
if output_dir:
|
||||
|
||||
Reference in New Issue
Block a user