Metadata-Version: 2.4
Name: mtrinicli
Version: 2.0.0
Summary: Mtrini IDE 2.0 - Sovereign Local AI Coding Agent by Oryvia Labs
Home-page: https://github.com/oryvia-labs/mtrini-ide
Author: Oryvia Labs
Author-email: ayham@oryvia.labs
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: fastapi>=0.100.0
Requires-Dist: uvicorn>=0.22.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: requests>=2.31.0
Requires-Dist: jinja2>=3.1.2
Requires-Dist: pyyaml>=6.0.1
Requires-Dist: sqlalchemy>=2.0.0
Requires-Dist: mcp>=0.1.0
Requires-Dist: passlib[bcrypt]>=1.7.4
Requires-Dist: bcrypt<4.0.0
Requires-Dist: python-jose[cryptography]>=3.3.0
Requires-Dist: python-multipart>=0.0.6
Requires-Dist: rich>=13.0.0
Requires-Dist: textual>=0.40.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.20; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Provides-Extra: desktop
Requires-Dist: electron; extra == "desktop"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Mtrini Studio

[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
[![Local AI](https://img.shields.io/badge/privacy-100%25%20Local-8b5cf6.svg)](#privacy--security)
[![PyPI](https://img.shields.io/pypi/v/mtrini-ide.svg)](https://pypi.org/project/mtrini-ide/)

> **Sovereign, local-first AI coding agent by Oryvia Labs.**
> 100% local. Zero cloud. Zero subscriptions.

---

## Free Tier

Mtrini Studio is **free forever** with 2 powerful AI models:

| Model | Size | Best For |
|---|---|---|
| **Mtrini Coder 2.0** | ~2.2 GB | Fast code completion, refactoring, debugging |
| **Mtrini Life 2.0** | ~1.8 GB | General assistant, writing, explanations |

No API key needed. No account required. No telemetry.

---

## Quickstart

### Install
```bash
pip install mtrinicli
```

### Launch
```bash
mtrini              # Launch TUI (default)
mtrini --cli        # Launch CLI mode
mtrini --web        # Launch web server
mtrini --setup      # First-time setup wizard
```

### Or run directly
```bash
python mtrini_ide.py
python mtrini_ide.py --cli
python mtrini_ide.py --setup
```

---

## What You Get

- **Local AI Agent** - Reads, writes, and edits your code using local LLMs
- **Plan & Build Modes** - Read-only analysis or full file system access
- **8 Built-in Tools** - Bash, read, write, edit, grep, glob, web search, web fetch
- **BYOK Support** - Use OpenAI, Anthropic, Google, Ollama, or any OpenAI-compatible API
- **Desktop App** - Native Electron window with dark glassmorphism UI
- **MCP Integration** - Connect external tool servers
- **Cascade Fallback** - Auto-downgrades models if your hardware can't handle the big ones

---

## BYOK (Bring Your Own Key)

Use any LLM provider via the OpenAI-compatible API format:

### Local Providers (Free, No API Key)
| Provider | URL |
|---|---|
| **Mtrini (Default)** | localhost:8080 |
| **Ollama** | localhost:11434 |
| **LM Studio** | localhost:1234 |
| **llama.cpp** | localhost:8080 |

### Cloud Providers (API Key Required)
| Provider | Models |
|---|---|
| **OpenAI** | GPT-4o, GPT-4o-mini, o1, o3-mini |
| **Anthropic** | Claude Sonnet 4, Claude Opus 4 |
| **Google Gemini** | Gemini 2.5 Flash, Gemini 2.5 Pro |
| **Groq** | Llama 3.3 70B, Mixtral 8x7B |
| **Together AI** | Llama 3.3 70B, Qwen 2.5 Coder 32B |
| **DeepSeek** | DeepSeek Chat, DeepSeek Coder |
| **OpenRouter** | 100+ models gateway |

---

## Architecture

```
mtrini-ide/
├── providers/          # BYOK provider system
│   ├── base.py         # BaseProvider abstract class
│   ├── openai_compat.py # Universal OpenAI-compatible adapter
│   ├── registry.py     # Provider registry + health checks
│   └── vault.py        # Encrypted API key storage
├── tools/              # Agent tool system
│   ├── base.py         # BaseTool with permission system
│   ├── registry.py     # Tool registry + execution
│   ├── bash.py         # Shell command execution
│   ├── read_file.py    # File reading with line numbers
│   ├── write_file.py   # File writing with auto-mkdir
│   ├── edit_file.py    # String replacement with diff preview
│   ├── grep.py         # Regex search (ripgrep + fallback)
│   ├── glob.py         # File pattern matching
│   ├── websearch.py    # DuckDuckGo web search
│   └── webfetch.py     # URL content fetching
├── engine/             # Agent loop engine
│   ├── agent.py        # Core agent loop (plan/build modes)
│   └── context.py      # Context window management
├── desktop/            # Electron desktop app
│   ├── main.js         # Electron main process
│   ├── preload.js      # Secure bridge
│   └── renderer/       # Frontend HTML/CSS/JS
├── app/                # FastAPI backend
│   ├── main.py         # OpenAI-compatible API server
│   ├── model.py        # llama-server process manager
│   └── mcp_manager.py  # MCP tool integration
├── models/             # Local GGUF model files
├── mtrini_ide.py       # Main entry point
└── config.yaml         # Configuration
```

---

## Agent Modes

### Plan Mode (Read-Only)
```bash
/plan    # Switch to plan mode
```
- Analyzes code without making changes
- Proposes implementation plans
- Identifies risks and edge cases

### Build Mode (Full Access)
```bash
/build   # Switch to build mode (default)
```
- Reads, writes, and edits files
- Runs shell commands
- Full tool access with permission controls

---

## Tool System

| Tool | Permission | Description |
|---|---|---|
| `bash` | ask | Execute shell commands |
| `read` | allow | Read file contents |
| `write` | ask | Create/overwrite files |
| `edit` | ask | String replacement with diff |
| `grep` | allow | Regex content search |
| `glob` | allow | File pattern matching |
| `websearch` | allow | Web search via DuckDuckGo |
| `webfetch` | allow | Fetch URL content |

---

## Slash Commands

| Command | Description |
|---|---|
| `/help` | Show all commands |
| `/clear` | Clear chat history |
| `/plan` | Switch to plan mode |
| `/build` | Switch to build mode |
| `/provider NAME` | Set active provider |
| `/model NAME` | Set active model |
| `/stats` | Show session statistics |
| `/undo` | Undo last response |
| `/support` | Support the project |
| `/exit` | Exit the IDE |

---

## Desktop App

```bash
cd desktop
npm install
npm start
```

Features:
- Native window with hidden title bar
- File tree sidebar
- Dark glassmorphism UI
- Settings panel for provider configuration
- System integration (menus, keyboard shortcuts)

---

## Privacy & Security

- **100% Local**: All inference runs on your hardware
- **Encrypted Keys**: API keys stored with XOR encryption in `~/.mtrini/vault.enc`
- **No Telemetry**: Zero data sent to external servers
- **Permission Controls**: Granular tool permissions per session

---

## Support the Project

If you enjoy Mtrini Studio, consider supporting its development:

- **Ko-fi**: [ko-fi.com/ayh4m](https://ko-fi.com/ayh4m)
- **GitHub Sponsors**: [github.com/sponsors/oryvialabs](https://github.com/sponsors/oryvialabs)

Your support helps keep Mtrini free and maintained.

---

## About Oryvia Labs

Built by **Oryvia Labs**, founded by **Ayham Habbad** based in Salé, Morocco.

- **PyPI**: [pypi.org/project/mtrini-ide](https://pypi.org/project/mtrini-ide/)
- **License**: Custom EULA - see [LICENSE.txt](LICENSE.txt)
