MibyanCLI so wrapper CLIs can add widgets, keybindings, and layout customizations without overriding the run() method or the TUI construction in mibyan_cli/cli_tui_mixin.py (where these hooks are defined; MibyanCLI in cli.py mixes it in). This keeps your extension decoupled from internal changes.
Extension points
There are five extension seams available:
The first three are new protected hooks. The last two already existed.
Quick start: a wrapper CLI
Hook reference
_get_extra_tui_widgets()
Returns a list of prompt_toolkit widgets to insert into the TUI layout. Widgets appear between the spacer and the status bar — above the input area but below the main output.
Window, ConditionalContainer, HSplit). Use ConditionalContainer or filter=Condition(...) to make widgets toggleable.
_register_extra_tui_keybindings(kb, *, input_area)
Called after Mibyan registers its own keybindings and before the layout is built. Add your keybindings to kb.
kb— TheKeyBindingsinstance for the prompt_toolkit applicationinput_area— The mainTextAreawidget, if you need to read or manipulate user input
Enter (submit), Escape Enter (newline), Ctrl-C (interrupt), Ctrl-D (exit), Tab (auto-suggest accept). Function keys F2+ and Ctrl-combinations are generally safe.
_build_tui_layout_children(**widgets)
Override this only when you need full control over widget ordering. Most extensions should use _get_extra_tui_widgets() instead.
None widgets are filtered out):
Layout diagram
The default layout from top to bottom:- Output area — scrolling conversation history
- Spacer
- Extra widgets — from
_get_extra_tui_widgets() - Status bar — model, context %, elapsed time
- Image bar — attached image count
- Input area — user prompt
- Voice status — recording indicator
- Completions menu — autocomplete suggestions
Tips
- Invalidate the display after state changes: call
self._invalidate()to trigger a prompt_toolkit redraw. - Access agent state:
self.agent,self.model,self.conversation_historyare all available. - Custom styles: Override
_build_tui_style_dict()and add entries for your custom style classes. - Slash commands: Override
process_command(), handle your commands, and callsuper().process_command(cmd)for everything else. - Don’t override
run()unless absolutely necessary — the extension hooks exist specifically to avoid that coupling.

