refactor: extract cli_config, cli_git, cli_display from cli.py (−2,158 lines) - #12355
refactor: extract cli_config, cli_git, cli_display from cli.py (−2,158 lines)#12355xandgate wants to merge 1 commit into
Conversation
|
🤖 Automated Refactor Review SummaryClean extraction of 1,327 lines from cli.py into 3 focused modules (cli_config.py, cli_git.py, cli_display.py). Good modularization effort. ✅ Imports & Dependencies
✅ API Compatibility
✅ State Management
|
|
Automated Refactor Review - PR #12355 SummaryClean extraction of 1,327 lines from cli.py into 3 focused modules. Good modularization. Critical Issuecli_config.py: _load_prefill_messages() uses _hermes_home variable that is NOT defined in the module. This variable was in cli.py but wasn't passed to the new module. Will cause NameError. Security Review: PASS
Verdict: NEEDS CHANGESFix the _hermes_home reference before merge. Suggest using get_hermes_home() import inside the function. |
|
Fixed in 477b7f2.
# before
path = _hermes_home / path # NameError in extracted module
# after
path = get_hermes_home() / path # consistent with rest of cli_config.pyGood catch — I had patched the two obvious |
477b7f2 to
9d31271
Compare
|
Rebased on current What conflicted: Two upstream commits landed while the PR was open:
How resolved:
All four files syntax-verified clean post-rebase. |
|
Thanks for the focused modularization work. This aligns with the repository’s stated goal of extracting coherent clusters from Problems
Suggested changes
This is an automated hermes-sweeper review. |
Re-extraction of PR NousResearch#12355 from the current head, per the sweeper review: the previous branch predated the synchronized-base worktree setup, worktree lock classification/pruning (74809b4), prefill precedence resolution, and the light-mode display path, so the modules are re-cut from today's implementations instead of rebasing the stale copies. - cli_config.py: config loading/saving, prefill message loading and precedence resolution, reasoning/service-tier parsing - cli_git.py: worktree isolation incl. sync_base setup, lock classification, stale-worktree pruning, orphaned-branch cleanup; active-worktree state now lives here behind get_active_worktree()/set_active_worktree() - cli_display.py: ANSI/skin helpers, light-mode detection/remap, output-history record/replay, file-drop and attachment detection, ChatConsole, banners, slash-command detection cli.py re-imports every moved name, so existing `from cli import X` call sites (mixins, tools, tests) keep working. Tests that monkeypatched moved module globals (_hermes_home, _LIGHT_MODE_CACHE, _pt_print, _OUTPUT_HISTORY) now patch the module that owns them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
9d31271 to
f469af6
Compare
|
Re-extracted from the current head per the review above (branch force-pushed; the previous April snapshot is superseded). Addressing each point:
All moves are verbatim from today's |
|
Coordination from the god-file decomposition campaign (epic #78647, cli.py target #55136): This PR overlaps cli.py's R1 region's two biggest extraction candidates:
Our double-blind consensus (2 independent analysts + adjudication, 2026-08-05) found this PR during the open-PR sweep and blocked both candidates on it — no R1 slice will be filed while this is open. If this merges, R1's C2/C5 work is pre-done and we re-derive the remaining cluster map from its diff (per the consensus execution order §4.1). Standing coordination: the campaign will re-scan the merge state before every R1 scheduling decision. If you'd like the full consensus file for reference: it's summarized at #78647 progress comments; the blocking map is in the campaign's R1-CONSENSUS.md. No conflicts intended — the extraction wave is proceeding on R2–R5 (windows 5613+), which this PR does not touch. |
Extracts three coherent clusters from the 16,280-line
cli.pyinto focused modules, per the god-file modularization goal inAGENTS.md:cli_config.py(609 lines): config loading/saving (load_cli_config,save_config_value), prefill message loading and precedence resolution, reasoning/service-tier parsingcli_git.py(701 lines): git worktree isolation — synchronized-base_setup_worktree, lock classification, stale-worktree pruning, orphaned-branch cleanup; active-worktree state behindget_active_worktree()/set_active_worktree()cli_display.py(1,015 lines): ANSI/skin helpers, light-mode detection/remap, output-history record/replay, file-drop and attachment detection,ChatConsole, banners, slash-command detectioncli.py: 16,280 → 14,122 lines (−13.3%). TheHermesCLIclass andmain()are untouched.All moves are verbatim from the current head.
cli.pyre-imports every moved name, so existingfrom cli import Xcall sites (mixins,tools/delegate_tool.py, tests) keep working. Tests that monkeypatched moved module globals now patch the owning module; the fulltests/cli+tests/hermes_clisuites show zero new failures vs a clean main baseline.History note: originally opened in April against a 10,536-line
cli.py; re-extracted from the current head in July per the hermes-sweeper review below (preserving thesync_baseworktree setup, lock-classification/pruning safety logic, prefill precedence, and light-mode paths that landed in between).🤖 Generated with Claude Code