Skip to main content
Mibyan exposes protected extension hooks on 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

Run it from your source checkout after selecting an isolated development home with the PM developer workflow:

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.
Each widget should be a prompt_toolkit container (e.g., 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.
Parameters:
  • kb — The KeyBindings instance for the prompt_toolkit application
  • input_area — The main TextArea widget, if you need to read or manipulate user input
Avoid conflicts with built-in keybindings: 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.
The default implementation returns (any None widgets are filtered out):

Layout diagram

The default layout from top to bottom:
  1. Output area — scrolling conversation history
  2. Spacer
  3. Extra widgets — from _get_extra_tui_widgets()
  4. Status bar — model, context %, elapsed time
  5. Image bar — attached image count
  6. Input area — user prompt
  7. Voice status — recording indicator
  8. 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_history are 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 call super().process_command(cmd) for everything else.
  • Don’t override run() unless absolutely necessary — the extension hooks exist specifically to avoid that coupling.