refactor(cli): split HermesCLI into 10 cohesive mixins (cli.py 22,284 -> 9,150)

326 methods lifted by AST (bodies identical; ast.dump-verified) into
hermes_cli/cli_{tui,status_bar,voice,model_switch,session,stream,modal,
terminal,info,loops}_mixin.py. cli.py-internal symbols resolve via lazy
'from cli import ...' inside each method (no import cycle; patch('cli.X')
keeps working). The three 'global' writers (_skill_commands, _cli_wake_owner)
now write the cli module attribute explicitly so the origin's readers still
see them. Dropped imports left unused in cli.py; kept display_hermes_home /
build_welcome_banner as re-exports (mixins + tests resolve them via cli).
Repointed two AST change-detector tests to cli_tui_mixin.py; one test
fixture now keeps 'cli' in sys.modules across its patch.dict scope.
This commit is contained in:
Teknium
2026-09-02 15:42:24 -07:00
parent 88b74d6ef0
commit eb74a00c71
14 changed files with 13604 additions and 13154 deletions
+9 -2
View File
@@ -54,8 +54,15 @@ def _make_cli(tool_progress="all", verbose=_UNSET):
with patch.object(mod, "get_tool_definitions", return_value=[]), \
patch.dict(mod.__dict__, {"CLI_CONFIG": _clean_config}):
if verbose is _UNSET:
return mod.HermesCLI()
return mod.HermesCLI(verbose=verbose)
inst = mod.HermesCLI()
else:
inst = mod.HermesCLI(verbose=verbose)
# patch.dict(sys.modules) above restores the pre-import state on exit, which
# DROPS ``cli`` when this was the first import. The mixin handlers resolve
# ``_cprint`` via a lazy ``from cli import ...``, so ``cli`` must stay
# registered for ``patch.object(_cli_mod, "_cprint")`` to intercept.
sys.modules["cli"] = mod
return inst
class TestToolProgressScrollback: