Skip to content

The agent that grows with you

refactor(hermes_cli): AST-neutral bracket hug/pack layout pass on g5-model files

Teknium5ddca91a318d
diff --git a/hermes_cli/bundles.py b/hermes_cli/bundles.py
index df00c3996c5..dc92b0af915 100644
--- a/hermes_cli/bundles.py
+++ b/hermes_cli/bundles.py
@@ -11,13 +11,7 @@ from rich.table import Table
from hermes_cli.cli_output import line_input
from agent.skill_bundles import (
- _bundles_dir,
- delete_bundle,
- get_bundle,
- list_bundles,
- reload_bundles,
- save_bundle,
- scan_bundles,
+ _bundles_dir, delete_bundle, get_bundle, list_bundles, reload_bundles, save_bundle, scan_bundles
)
@@ -97,10 +91,7 @@ def _cmd_create(args) -> None:
try:
path = save_bundle(
- name,
- skills,
- description=args.description or "",
- instruction=args.instruction or "",
+ name, skills, description=args.description or "", instruction=args.instruction or "",
overwrite=bool(args.force),
)
except FileExistsError as exc:
@@ -177,8 +168,7 @@ def register_cli(subparser) -> None:
help="Extra guidance prepended to the loaded skill content",
)
p_create.add_argument(
- "--force", "-f", action="store_true",
- help="Overwrite an existing bundle with the same name",
+ "--force", "-f", action="store_true", help="Overwrite an existing bundle with the same name"
)
p_create.set_defaults(_bundles_handler=_cmd_create)
diff --git a/hermes_cli/cli_model_switch_mixin.py b/hermes_cli/cli_model_switch_mixin.py
index b25508e923e..2aa46c43972 100644
--- a/hermes_cli/cli_model_switch_mixin.py
+++ b/hermes_cli/cli_model_switch_mixin.py
@@ -95,11 +95,9 @@ def _print_switch_summary(cli, result, old_model, *, one_turn: bool, strict_cont
agent = cli.agent
try:
ctx = resolve_display_context_length(
- result.new_model,
- result.target_provider,
+ result.new_model, result.target_provider,
base_url=result.base_url or cli.base_url or "",
- api_key=result.api_key or cli.api_key or "",
- model_info=mi,
+ api_key=result.api_key or cli.api_key or "", model_info=mi,
config_context_length=getattr(agent, "_config_context_length", None) if agent else None,
custom_providers=getattr(agent, "_custom_providers", None) if agent else None,
)
@@ -147,8 +145,7 @@ def _show_model_picker(cli, ctx, force_refresh: bool) -> None:
if ctx is None:
raise RuntimeError("inventory context unavailable")
providers = build_models_payload(
- ctx,
- probe_custom_providers=force_refresh,
+ ctx, probe_custom_providers=force_refresh,
probe_current_custom_provider=not force_refresh,
)["providers"]
except Exception:
@@ -164,9 +161,7 @@ def _show_model_picker(cli, ctx, force_refresh: bool) -> None:
_cprint(" /model --refresh re-fetch live model lists")
return
cli._open_model_picker(
- providers,
- cli.model or "unknown",
- get_label(cli.provider) if cli.provider else "unknown",
+ providers, cli.model or "unknown", get_label(cli.provider) if cli.provider else "unknown",
user_provs=ctx.user_providers if ctx is not None else None,
custom_provs=ctx.custom_providers if ctx is not None else None,
)
@@ -201,8 +196,7 @@ class CLIModelSwitchMixin:
try:
from hermes_cli.model_normalize import (
- _AGGREGATOR_PROVIDERS,
- normalize_model_for_provider,
+ _AGGREGATOR_PROVIDERS, normalize_model_for_provider
)
if resolved_provider not in _AGGREGATOR_PROVIDERS:
_adopt(
@@ -368,11 +362,8 @@ class CLIModelSwitchMixin:
if self.agent is not None:
try:
self.agent.switch_model(
- new_model=self.model,
- new_provider=self.provider,
- api_key=self.api_key or "",
- base_url=self.base_url or "",
- api_mode=self.api_mode or "",
+ new_model=self.model, new_provider=self.provider, api_key=self.api_key or "",
+ base_url=self.base_url or "", api_mode=self.api_mode or "",
)
except Exception:
logger.debug("In-place agent model swap on resume failed", exc_info=True)
@@ -406,11 +397,9 @@ class CLIModelSwitchMixin:
try:
from hermes_cli.model_selection_guards import combined_selection_warning
warning = combined_selection_warning(
- result.new_model,
- provider=result.target_provider,
+ result.new_model, provider=result.target_provider,
base_url=result.base_url or self.base_url or "",
- api_key=result.api_key or self.api_key or "",
- model_info=result.model_info,
+ api_key=result.api_key or self.api_key or "", model_info=result.model_info,
)
except Exception:
warning = None
@@ -479,10 +468,8 @@ class CLIModelSwitchMixin:
if hasattr(agent, "switch_model"):
try:
agent.switch_model(
- new_model=snapshot.get("model", ""),
- new_provider=snapshot.get("provider", ""),
- api_key=snapshot.get("api_key", ""),
- base_url=snapshot.get("base_url", ""),
+ new_model=snapshot.get("model", ""), new_provider=snapshot.get("provider", ""),
+ api_key=snapshot.get("api_key", ""), base_url=snapshot.get("base_url", ""),
api_mode=snapshot.get("api_mode", ""),
capabilities=snapshot.get("capabilities"),
)
@@ -510,13 +497,8 @@ class CLIModelSwitchMixin:
@staticmethod
def _compute_model_picker_viewport(
- selected: int,
- scroll_offset: int,
- n: int,
- term_rows: int,
- reserved_below: int = 6,
- panel_chrome: int = 6,
- min_visible: int = 3,
+ selected: int, scroll_offset: int, n: int, term_rows: int, reserved_below: int = 6,
+ panel_chrome: int = 6, min_visible: int = 3,
) -> tuple[int, int]:
"""Resolve (scroll_offset, visible) for the /model picker viewport.
@@ -545,12 +527,9 @@ class CLIModelSwitchMixin:
if not isinstance(model_cfg, dict) or "context_length" not in model_cfg:
return
if should_clear_context_pin(
- model_cfg.get("default") or model_cfg.get("model"),
- result.new_model,
- model_cfg.get("base_url"),
- result.base_url,
- model_cfg.get("provider"),
- result.target_provider,
+ model_cfg.get("default") or model_cfg.get("model"), result.new_model,
+ model_cfg.get("base_url"), result.base_url,
+ model_cfg.get("provider"), result.target_provider,
):
save_config_value("model.context_length", None)
except Exception:
@@ -584,11 +563,8 @@ class CLIModelSwitchMixin:
if self.agent is not None:
try:
self.agent.switch_model(
- new_model=result.new_model,
- new_provider=result.target_provider,
- api_key=result.api_key,
- base_url=result.base_url,
- api_mode=result.api_mode,
+ new_model=result.new_model, new_provider=result.target_provider,
+ api_key=result.api_key, base_url=result.base_url, api_mode=result.api_mode,
capabilities=getattr(result, "runtime_capabilities", None),
)
except Exception as exc:
@@ -676,12 +652,9 @@ class CLIModelSwitchMixin:
if 0 <= selected < back_idx:
from hermes_cli.model_switch import switch_model
result = switch_model(
- raw_input=visible_labels[selected],
- current_provider=self.provider or "",
- current_model=self.model or "",
- current_base_url=self.base_url or "",
- current_api_key=self.api_key or "",
- is_global=persist_global,
+ raw_input=visible_labels[selected], current_provider=self.provider or "",
+ current_model=self.model or "", current_base_url=self.base_url or "",
+ current_api_key=self.api_key or "", is_global=persist_global,
explicit_provider=provider_data.get("slug"),
user_providers=state.get("user_provs"),
custom_providers=state.get("custom_provs"),
@@ -692,8 +665,7 @@ class CLIModelSwitchMixin:
if getattr(self, "_app", None):
threading.Thread(
target=self._confirm_and_apply_model_switch_result,
- args=(result, persist_global, _picker_custom_provs),
- daemon=True,
+ args=(result, persist_global, _picker_custom_provs), daemon=True,
).start()
else:
self._confirm_and_apply_model_switch_result(
@@ -719,9 +691,7 @@ class CLIModelSwitchMixin:
"""
from cli import _cprint
from hermes_cli.model_switch import (
- switch_model,
- parse_model_switch_args,
- resolve_persist_behavior,
+ switch_model, parse_model_switch_args, resolve_persist_behavior
)
parts = cmd_original.split(None, 1) # split off '/model'
@@ -753,8 +723,7 @@ class CLIModelSwitchMixin:
from hermes_cli.inventory import load_picker_context
try:
ctx = load_picker_context().with_overrides(
- current_provider=self.provider or "",
- current_model=self.model or "",
+ current_provider=self.provider or "", current_model=self.model or "",
current_base_url=self.base_url or "",
)
except Exception:
@@ -767,14 +736,10 @@ class CLIModelSwitchMixin:
return _show_model_picker(self, ctx, request.force_refresh)
result = switch_model(
- raw_input=request.target,
- current_provider=self.provider or "",
- current_model=self.model or "",
- current_base_url=self.base_url or "",
- current_api_key=self.api_key or "",
- is_global=persist_global,
- explicit_provider=request.explicit_provider,
- user_providers=user_provs,
+ raw_input=request.target, current_provider=self.provider or "",
+ current_model=self.model or "", current_base_url=self.base_url or "",
+ current_api_key=self.api_key or "", is_global=persist_global,
+ explicit_provider=request.explicit_provider, user_providers=user_provs,
custom_providers=custom_provs,
)
if not result.success:
@@ -789,8 +754,7 @@ class CLIModelSwitchMixin:
if getattr(self, "_app", None):
threading.Thread(
target=self._confirm_and_apply_cli_model_switch,
- args=(result, persist_global, one_turn, custom_provs),
- daemon=True,
+ args=(result, persist_global, one_turn, custom_provs), daemon=True,
).start()
return
self._confirm_and_apply_cli_model_switch(result, persist_global, one_turn, custom_provs)
diff --git a/hermes_cli/cli_stream_mixin.py b/hermes_cli/cli_stream_mixin.py
index 828378f1df9..7d526eccc20 100644
--- a/hermes_cli/cli_stream_mixin.py
+++ b/hermes_cli/cli_stream_mixin.py
@@ -25,12 +25,9 @@ _MAX_CLOSE_TAG_LEN = max(len(t) for t in _CLOSE_TAGS)
# Ordered (prefix, status) rows for _slow_command_status — first match wins.
_SLOW_COMMAND_STATUS = (
- ("/skills search", "Searching skills..."),
- ("/skills browse", "Loading skills..."),
- ("/skills inspect", "Inspecting skill..."),
- ("/skills install", "Installing skill..."),
- ("/skills", "Processing skills command..."),
- ("/browser", "Configuring browser..."),
+ ("/skills search", "Searching skills..."), ("/skills browse", "Loading skills..."),
+ ("/skills inspect", "Inspecting skill..."), ("/skills install", "Installing skill..."),
+ ("/skills", "Processing skills command..."), ("/browser", "Configuring browser..."),
)
_SLOW_COMMAND_STATUS_EXACT = {
"/reload-mcp": "Reloading MCP servers...",
@@ -386,9 +383,7 @@ class CLIStreamMixin:
realigner pads to the final visible cell width, not the marker-decorated width.
"""
from cli import (
- _strip_markdown_syntax,
- _terminal_width_for_streaming,
- realign_markdown_tables,
+ _strip_markdown_syntax, _terminal_width_for_streaming, realign_markdown_tables
)
buf = self._stream_table_buf
self._stream_table_buf = []
@@ -405,15 +400,8 @@ class CLIStreamMixin:
def _emit_stream_text(self, text: str) -> None:
"""Emit filtered text to the streaming display."""
from cli import (
- HermesCLI,
- _ACCENT,
- _RST,
- _STREAM_PARTIAL_PREVIEW_LEN,
- _cprint,
- _strip_markdown_syntax,
- datetime,
- is_table_divider,
- looks_like_table_row,
+ HermesCLI, _ACCENT, _RST, _STREAM_PARTIAL_PREVIEW_LEN, _cprint, _strip_markdown_syntax,
+ datetime, is_table_divider, looks_like_table_row,
)
if not text:
return
@@ -493,12 +481,7 @@ class CLIStreamMixin:
def _flush_stream(self) -> None:
"""Emit any remaining partial line from the stream buffer and close the box."""
from cli import (
- _ACCENT,
- _RST,
- _cprint,
- _strip_markdown_syntax,
- is_table_divider,
- looks_like_table_row,
+ _ACCENT, _RST, _cprint, _strip_markdown_syntax, is_table_divider, looks_like_table_row
)
# Still inside a "reasoning block" at end-of-stream means a false positive — the
# model mentioned a tag like <think> in prose and never closed it. Recover the
@@ -754,10 +737,7 @@ class CLIStreamMixin:
and duration >= 30.0
):
from agent.onboarding import (
- TOOL_PROGRESS_FLAG,
- is_seen,
- mark_seen,
- tool_progress_hint_cli,
+ TOOL_PROGRESS_FLAG, is_seen, mark_seen, tool_progress_hint_cli
)
if not is_seen(CLI_CONFIG, TOOL_PROGRESS_FLAG):
self._long_tool_hint_fired = True
@@ -817,10 +797,7 @@ class CLIStreamMixin:
try:
from agent.display import render_edit_diff_with_delta
render_edit_diff_with_delta(
- function_name,
- function_result,
- function_args=function_args,
- snapshot=snapshot,
+ function_name, function_result, function_args=function_args, snapshot=snapshot,
print_fn=_cprint,
)
except Exception:
diff --git a/hermes_cli/cli_voice_mixin.py b/hermes_cli/cli_voice_mixin.py
index 58e69e94c14..0fa69ac13ac 100644
--- a/hermes_cli/cli_voice_mixin.py
+++ b/hermes_cli/cli_voice_mixin.py
@@ -454,11 +454,8 @@ class CLIVoiceMixin:
logger.debug("voice interjection interrupt failed: %s", e)
wav_path = full_duplex_listen(
- _should_stop,
- is_playing=is_audio_output_active,
- on_trigger=_on_trigger,
- multiplier=_mult or None,
- grace_ms=max(0, _grace_ms),
+ _should_stop, is_playing=is_audio_output_active, on_trigger=_on_trigger,
+ multiplier=_mult or None, grace_ms=max(0, _grace_ms),
)
if wav_path and self._voice_barge_capture.is_set():
self._voice_submit_barge_utterance(wav_path)
@@ -491,8 +488,7 @@ class CLIVoiceMixin:
from tools.voice_mode import is_tts_echo
if is_tts_echo(transcript, getattr(self, "_voice_last_tts_text", "")):
logger.debug(
- "Dropping playback-phase barge transcript as TTS echo: %r",
- transcript,
+ "Dropping playback-phase barge transcript as TTS echo: %r", transcript
)
_cprint(f"\n{_DIM}Ignored likely TTS echo (not queued).{_RST}")
return
@@ -658,10 +654,7 @@ class CLIVoiceMixin:
from cli import _ACCENT, _DIM, _RST, _cprint
try:
from tools.wake_word import (
- check_wake_word_requirements,
- load_wake_word_config,
- owns_listener,
- start_listening,
+ check_wake_word_requirements, load_wake_word_config, owns_listener, start_listening
)
except Exception as e:
if announce:
@@ -831,10 +824,7 @@ class CLIVoiceMixin:
"""Show current wake-word listener status."""
from cli import _ACCENT, _BOLD, _DIM, _RST, _cprint
from tools.wake_word import (
- audio_is_silent,
- check_wake_word_requirements,
- is_listening,
- load_wake_word_config,
+ audio_is_silent, check_wake_word_requirements, is_listening, load_wake_word_config,
owns_listener,
)
diff --git a/hermes_cli/codex_models.py b/hermes_cli/codex_models.py
index ae035cb23af..7191806ef24 100644
--- a/hermes_cli/codex_models.py
+++ b/hermes_cli/codex_models.py
@@ -193,7 +193,6 @@ def get_codex_model_ids(access_token: Optional[str] = None) -> List[str]:
return _finalize_codex_models(api_models)
default_model = _read_default_model(codex_home)
return _finalize_codex_models(_dedupe([
- *([default_model] if default_model else []),
- *_read_cache_models(codex_home),
+ *([default_model] if default_model else []), *_read_cache_models(codex_home),
*DEFAULT_CODEX_MODELS,
]))