ui/terminal/ - MIRA Terminal Client
Interactive CLI for chatting with MIRA. Supports local (localhost:1993) and online (miraos.org) modes.
Files
__init__.py- Package init, exportsmain()__main__.py-python -m ui.terminalentry pointapp.py-MiraTerminalclass: chat loop, prompt_toolkit, bottom toolbar, server management,main()entry point with argparseapi.py-MiraClientclass: all HTTP calls to MIRA API. Alsocheck_for_update()andstrip_emotion_tag()standalone functionsconfig.py-TerminalConfig(Pydantic BaseModel): JSON config at~/.mira/terminal.json. Handles mode-based URL/token resolutionrenderer.py- Output functions:print_user_message,print_mira_response,print_thinking,print_error,print_tool_use,print_info. Uses prompt_toolkitprint_formatted_text(thread-safe withpatch_stdout)commands.py- Slash command dispatch viaCOMMANDSdict: /help, /tier, /status, /collapse, /domaindoc, /settings, /clearsettings.py- Interactive settings UI with numbered enter-to-toggle list
Key Patterns
- Prompt layout: Separator line (
─) +❯input in_get_prompt_message(), status bar (tier, domaindocs, loading, update) in_get_bottom_toolbar()below the input. Both re-evaluated onapp.invalidate().erase_when_done=Trueprevents prompt echo duplication - Background API calls:
threading.Thread+patch_stdout()— response prints above the active prompt. Animation thread cycles_loading_frameand invalidates - Enter suppression: Custom key binding swallows Enter while
self.loadingis True - Dual mode: Config
modefield ("local"/"online") controls URL and token resolution. Local uses Vault, online uses stored API key - Domaindoc editing: Opens content in
$EDITOR(config.editor, default nano) via tempfile, saves back through API - Server auto-start: Local mode only. Shows
[MIRA IS STARTING], overwrites line when ready
Entry Points
python talkto_mira.py→ui.terminal.main()python -m ui.terminal→ same--headless "msg"for one-shot,--show-keyfor API key display