feat(cli): TUI extension hooks — build custom CLIs on top of Hermes#2333
Merged
feat(cli): TUI extension hooks — build custom CLIs on top of Hermes#2333
Conversation
Based on PR #1749 by @erosika (reimplemented on current main). Extracts three protected methods from run() so wrapper CLIs can extend the TUI without overriding the entire method: - _get_extra_tui_widgets(): inject widgets between spacer and status bar - _register_extra_tui_keybindings(kb, input_area): add keybindings - _build_tui_layout_children(**widgets): full control over ordering Default implementations reproduce existing layout exactly. The inline HSplit in run() now delegates to _build_tui_layout_children(). 5 tests covering defaults, widget insertion position, and keybinding registration.
0fdda03 to
d70e07f
Compare
Streaming provides a better UX — tokens appear as they arrive instead of waiting for the full response. show_reasoning remains false so thinking blocks are not streamed to the user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on PR #1749 by @erosika (reimplemented on current main — original was 200+ commits behind).
What this does
Extracts three protected methods from
HermesCLI.run()so wrapper CLIs can extend the TUI without overriding the entire 1000+ line method:_get_extra_tui_widgets()— inject widgets (between spacer and status bar)_register_extra_tui_keybindings(kb, *, input_area)— add keybindings_build_tui_layout_children(**widgets)— full control over widget orderingDefault implementations reproduce existing layout exactly. Zero behavior change for existing users.
What this enables
The TUI extension hooks let anyone build a custom CLI on top of Hermes without forking or monkey-patching. Subclass
HermesCLI, override a few methods, and you have a branded product with its own UI elements and shortcuts — while inheriting all of Hermes's agent loop, tool system, memory, sessions, and provider infrastructure.The key value: none of these need to touch
run()or track upstream changes to the layout code. The hooks are stable API surface — upstream can rearrange internals and the wrapper keeps working.Changes
cli.py: 3 new protected methods + refactoredrun()layout to use_build_tui_layout_children()tests/test_cli_extension_hooks.py: 5 tests covering defaults, widget insertion, and keybinding registrationwebsite/docs/developer-guide/extending-the-cli.md: full documentation with working example, hook reference, layout diagram, and tipswebsite/sidebars.ts: added to Developer Guide navigation5697 tests passing.