CodeDocs Vault

Mistral Vibe - Architecture Overview

What is Mistral Vibe?

Mistral Vibe is an open-source CLI coding assistant developed by Mistral AI. It provides a conversational AI interface for developers to interact with codebases through natural language commands directly from the terminal.

Version: 2.0.2 License: Apache 2.0 Python Requirement: 3.12+

Core Capabilities

High-Level Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        User Interface                            │
│  ┌─────────────────┐              ┌─────────────────────────┐   │
│  │ Interactive TUI │              │   Programmatic Mode     │   │
│  │ (Textual App)   │              │   (--prompt flag)       │   │
│  └────────┬────────┘              └───────────┬─────────────┘   │
└───────────┼───────────────────────────────────┼─────────────────┘
            │                                   │
            └───────────────┬───────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────────┐
│                         Agent Core                               │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                  AgentLoop Orchestrator                  │    │
│  │               (vibe/core/agent_loop.py)                  │    │
│  │  - Conversation state management                         │    │
│  │  - Message history                                       │    │
│  │  - Statistics tracking                                   │    │
│  └─────────────────────────┬───────────────────────────────┘    │
│                            │                                     │
│  ┌──────┬──────┬───────────┼───────┬──────────┬───────────┐     │
│  │      │      │           │       │          │           │     │
│  ▼      ▼      ▼           ▼       ▼          ▼           ▼     │
│ LLM   Tool  Middlew.    System   Session    Agent       Skill   │
│Backend Manager Pipeline  Prompt   Logger   Manager     Manager  │
└─────────────────────────────────────────────────────────────────┘
            │             │
            ▼             ▼
┌───────────────────┐  ┌──────────────────────────────────────────┐
│   LLM Providers   │  │              Tool Ecosystem              │
│  - Mistral API    │  │  ┌─────────┐ ┌─────────┐ ┌───────────┐  │
│  - Generic/OpenAI │  │  │Built-in │ │ Custom  │ │   MCP     │  │
│                   │  │  │ Tools   │ │ Tools   │ │   Tools   │  │
└───────────────────┘  │  └─────────┘ └─────────┘ └───────────┘  │
                       └──────────────────────────────────────────┘

Technology Stack

Component Technology Purpose
Language Python 3.12+ Modern syntax, type hints
TUI Framework Textual Rich terminal UI
LLM SDK mistralai Native Mistral API
External Tools MCP (mcp>=1.14.0) Tool extensibility
Configuration Pydantic v2 Validation & settings
Async Runtime asyncio Non-blocking I/O
HTTP Client httpx API communication
File I/O aiofiles Async file operations
YAML Parsing pyyaml Skill frontmatter
TOML Writing tomli_w Config persistence

Directory Structure

mistral-vibe/
├── vibe/                          # Main application package
│   ├── cli/                       # CLI and TUI components
│   │   ├── entrypoint.py         # CLI argument parsing, trust check
│   │   ├── cli.py                # run_cli() orchestrator
│   │   ├── terminal_setup.py     # Terminal keybinding setup
│   │   ├── commands.py           # Slash command registry
│   │   └── textual_ui/           # Textual TUI implementation
│   │       ├── app.py            # Main TUI application
│   │       ├── external_editor.py # External editor integration
│   │       ├── terminal_theme.py # Terminal theme detection
│   │       ├── handlers/         # Event handling
│   │       └── widgets/          # UI components
│   │           ├── question_app.py    # Ask user question UI
│   │           ├── agent_indicator.py # Agent profile display
│   │           ├── spinner.py         # Loading spinners
│   │           ├── status_message.py  # Status messages
│   │           ├── no_markup_static.py # Safe text display
│   │           └── ...
│   │
│   ├── core/                      # Core agent logic
│   │   ├── agent_loop.py         # Main orchestrator (AgentLoop)
│   │   ├── config.py             # Configuration system
│   │   ├── types.py              # Type definitions
│   │   ├── middleware.py         # Conversation middleware
│   │   ├── system_prompt.py      # Prompt construction
│   │   ├── trusted_folders.py    # Trusted folders security
│   │   │
│   │   ├── agents/               # Agent profile system
│   │   │   ├── models.py         # AgentProfile, AgentSafety, AgentType
│   │   │   └── manager.py        # AgentManager discovery & switching
│   │   │
│   │   ├── skills/               # Skills system
│   │   │   ├── models.py         # SkillMetadata, SkillInfo
│   │   │   ├── manager.py        # SkillManager discovery
│   │   │   └── parser.py         # YAML frontmatter parser
│   │   │
│   │   ├── session/              # Session persistence
│   │   │   ├── session_logger.py # Session creation & saving
│   │   │   ├── session_loader.py # Session finding & loading
│   │   │   └── session_migration.py # v1→v2 format migration
│   │   │
│   │   ├── paths/                # Path resolution
│   │   │   ├── global_paths.py   # GlobalPath, VIBE_HOME, etc.
│   │   │   └── config_paths.py   # Trust-aware config resolution
│   │   │
│   │   ├── llm/                  # LLM backend abstraction
│   │   │   └── backend/          # Provider implementations
│   │   │
│   │   └── tools/                # Tool system
│   │       ├── base.py           # Abstract base tool, InvokeContext
│   │       ├── manager.py        # Tool discovery
│   │       ├── ui.py             # ToolUIData protocol
│   │       ├── mcp.py            # MCP integration
│   │       └── builtins/         # Built-in tools
│   │           ├── ask_user_question.py  # Structured Q&A
│   │           ├── task.py              # Subagent delegation
│   │           └── ...
│   │
│   ├── acp/                       # Agent Client Protocol
│   └── setup/                     # Onboarding & trust dialogs
│
├── tests/                         # Test suite
└── docs/                          # Documentation

Key Design Principles

1. Plugin-Based Tool Architecture

Tools are discovered dynamically from multiple paths:

2. Agent Profile System

Switchable behavioral presets that modify config:

3. Skills System

Injectable knowledge via SKILL.md files:

4. Trusted Folders

Security boundary for project-local content:

5. Async-First Design

All I/O operations are async for responsiveness:

6. Middleware Pipeline

Extensible pre/post turn hooks:

7. Event-Driven Communication

AgentLoop yields events via AsyncGenerator:

Execution Modes

Interactive Mode (Default)

Full Textual TUI with:

Programmatic Mode (--prompt)

Non-interactive execution:

ACP Server Mode (vibe-acp)

Agent Client Protocol server:

Configuration Hierarchy

  1. Local project: ./.vibe/config.toml (if trusted)
  2. User home: ~/.vibe/config.toml
  3. Environment variables: VIBE_* prefix
  4. API keys: ~/.vibe/.env

Next Steps

For detailed documentation on specific components: