2.1 #2

Merged
rune merged 10 commits from 2.1 into main 2026-02-03 09:02:44 +01:00
2 changed files with 831 additions and 38 deletions
Showing only changes of commit 106ef676e2 - Show all commits

View File

@@ -28,6 +28,14 @@ oAI is a feature-rich command-line chat application that provides an interactive
- Supports code files, text, JSON, YAML, and more - Supports code files, text, JSON, YAML, and more
- Large file handling (auto-truncates >50KB) - Large file handling (auto-truncates >50KB)
- ✍️ **Write Mode** (NEW!): AI can modify files with your permission
- Create and edit files within allowed folders
- Delete files (always requires confirmation)
- Move, copy, and organize files
- Create directories
- Ignores .gitignore for write operations
- OFF by default - explicit opt-in required
- 🗄️ **Database Mode**: AI can query your SQLite databases - 🗄️ **Database Mode**: AI can query your SQLite databases
- Read-only access (no data modification possible) - Read-only access (no data modification possible)
- Schema inspection (tables, columns, indexes) - Schema inspection (tables, columns, indexes)
@@ -39,6 +47,8 @@ oAI is a feature-rich command-line chat application that provides an interactive
- 🔒 **Security Features**: - 🔒 **Security Features**:
- Explicit folder/database approval required - Explicit folder/database approval required
- System directory blocking - System directory blocking
- Write mode OFF by default (non-persistent)
- Delete operations always require user confirmation
- Read-only database access - Read-only database access
- SQL injection protection - SQL injection protection
- Query timeout (5 seconds) - Query timeout (5 seconds)
@@ -133,13 +143,18 @@ oai
You> /model You> /model
# Enable MCP for file access # Enable MCP for file access
You> /mcp enable You> /mcp on
You> /mcp add ~/Documents You> /mcp add ~/Documents
# Ask AI to help with files # Ask AI to help with files (read-only)
[🔧 MCP: Files] You> List all Python files in Documents [🔧 MCP: Files] You> List all Python files in Documents
[🔧 MCP: Files] You> Read and explain main.py [🔧 MCP: Files] You> Read and explain main.py
# Enable write mode to let AI modify files
You> /mcp write on
[🔧✍️ MCP: Files+Write] You> Create a new Python file with helper functions
[🔧✍️ MCP: Files+Write] You> Refactor main.py to use async/await
# Switch to database mode # Switch to database mode
You> /mcp add db ~/myapp/data.db You> /mcp add db ~/myapp/data.db
You> /mcp db 1 You> /mcp db 1
@@ -153,7 +168,7 @@ You> /mcp db 1
**Setup:** **Setup:**
```bash ```bash
/mcp enable # Start MCP server /mcp on # Start MCP server
/mcp add ~/Projects # Grant access to folder /mcp add ~/Projects # Grant access to folder
/mcp add ~/Documents # Add another folder /mcp add ~/Documents # Add another folder
/mcp list # View all allowed folders /mcp list # View all allowed folders
@@ -167,16 +182,26 @@ You> /mcp db 1
"What's in my Documents folder?" "What's in my Documents folder?"
``` ```
**Available Tools:** **Available Tools (Read-Only):**
- `read_file` - Read complete file contents - `read_file` - Read complete file contents
- `list_directory` - List files/folders (recursive optional) - `list_directory` - List files/folders (recursive optional)
- `search_files` - Search by name or content - `search_files` - Search by name or content
**Available Tools (Write Mode - requires `/mcp write on`):**
- `write_file` - Create new files or overwrite existing ones
- `edit_file` - Find and replace text in existing files
- `delete_file` - Delete files (always requires confirmation)
- `create_directory` - Create directories
- `move_file` - Move or rename files
- `copy_file` - Copy files to new locations
**Features:** **Features:**
- ✅ Automatic .gitignore filtering - ✅ Automatic .gitignore filtering (read operations only)
- ✅ Skips virtual environments (venv, node_modules) - ✅ Skips virtual environments (venv, node_modules)
- ✅ Handles large files (auto-truncates >50KB) - ✅ Handles large files (auto-truncates >50KB)
- ✅ Cross-platform (macOS, Linux, Windows via WSL) - ✅ Cross-platform (macOS, Linux, Windows via WSL)
- ✅ Write mode OFF by default for safety
- ✅ Delete operations require user confirmation with LLM's reason
### Database Mode ### Database Mode
@@ -210,13 +235,41 @@ You> /mcp db 1
- ✅ WHERE, GROUP BY, HAVING, ORDER BY, LIMIT - ✅ WHERE, GROUP BY, HAVING, ORDER BY, LIMIT
- ❌ INSERT/UPDATE/DELETE (blocked for safety) - ❌ INSERT/UPDATE/DELETE (blocked for safety)
### Write Mode
**Enable Write Mode:**
```bash
/mcp write on # Enable write mode (shows warning, requires confirmation)
```
**Natural Language Usage:**
```
"Create a new Python file called utils.py with helper functions"
"Edit main.py and replace the old API endpoint with the new one"
"Delete the backup.old file" (will prompt for confirmation)
"Create a directory called tests"
"Move config.json to the config folder"
```
**Important:**
- ⚠️ Write mode is **OFF by default** and resets each session
- ⚠️ Delete operations **always** require user confirmation
- ⚠️ All operations are limited to allowed MCP folders
- ✅ Write operations ignore .gitignore (can write to any file in allowed folders)
**Disable Write Mode:**
```bash
/mcp write off # Disable write mode (back to read-only)
```
### Mode Management ### Mode Management
```bash ```bash
/mcp status # Show current mode, stats, folders/databases /mcp status # Show current mode, write mode, stats, folders/databases
/mcp files # Switch to file mode /mcp files # Switch to file mode
/mcp db <number> # Switch to database mode /mcp db <number> # Switch to database mode
/mcp gitignore on # Enable .gitignore filtering (default) /mcp gitignore on # Enable .gitignore filtering (default)
/mcp write on|off # Enable/disable write mode
/mcp remove 2 # Remove folder/database by number /mcp remove 2 # Remove folder/database by number
``` ```
@@ -238,9 +291,9 @@ You> /mcp db 1
### MCP Commands ### MCP Commands
``` ```
/mcp enable Start MCP server /mcp on Start MCP server
/mcp disable Stop MCP server /mcp off Stop MCP server
/mcp status Show comprehensive status /mcp status Show comprehensive status (includes write mode)
/mcp add <folder> Add folder for file access /mcp add <folder> Add folder for file access
/mcp add db <path> Add SQLite database /mcp add db <path> Add SQLite database
/mcp list List all folders /mcp list List all folders
@@ -249,6 +302,8 @@ You> /mcp db 1
/mcp files Switch to file mode /mcp files Switch to file mode
/mcp remove <num> Remove folder/database /mcp remove <num> Remove folder/database
/mcp gitignore on Enable .gitignore filtering /mcp gitignore on Enable .gitignore filtering
/mcp write on Enable write mode (create/edit/delete files)
/mcp write off Disable write mode (read-only)
``` ```
### Model Commands ### Model Commands
@@ -356,7 +411,11 @@ PDF (models with document support)
- ✅ Database opened in `mode=ro` - ✅ Database opened in `mode=ro`
### File System Safety ### File System Safety
- ✅ Read-only access (no write/delete) - ✅ Read-only by default (write mode requires explicit opt-in)
- ✅ Write mode OFF by default each session (non-persistent)
- ✅ Delete operations always require user confirmation
- ✅ Write operations limited to allowed folders only
- ✅ System directories blocked
- ✅ Virtual environment exclusion - ✅ Virtual environment exclusion
- ✅ Build artifact filtering - ✅ Build artifact filtering
- ✅ Maximum file size (10 MB) - ✅ Maximum file size (10 MB)
@@ -444,14 +503,19 @@ ls -la database.db
## Version History ## Version History
### v2.1.0-beta (Current) ### v2.1.0-RC1 (Current)
-**NEW**: MCP (Model Context Protocol) integration -**NEW**: MCP (Model Context Protocol) integration
-**NEW**: File system access (read, search, list) -**NEW**: File system access (read, search, list)
-**NEW**: Write mode - AI can create, edit, and delete files
- 6 write tools: write_file, edit_file, delete_file, create_directory, move_file, copy_file
- OFF by default - requires explicit `/mcp write on` activation
- Delete operations always require user confirmation
- Non-persistent setting (resets each session)
-**NEW**: SQLite database querying (read-only) -**NEW**: SQLite database querying (read-only)
-**NEW**: Dual mode support (Files & Database) -**NEW**: Dual mode support (Files & Database)
-**NEW**: .gitignore filtering -**NEW**: .gitignore filtering
-**NEW**: Binary data handling in databases -**NEW**: Binary data handling in databases
-**NEW**: Mode indicators in prompt -**NEW**: Mode indicators in prompt (shows ✍️ when write mode active)
-**NEW**: Comprehensive `/help mcp` guide -**NEW**: Comprehensive `/help mcp` guide
- 🔧 Improved error handling for tool calls - 🔧 Improved error handling for tool calls
- 🔧 Enhanced logging for MCP operations - 🔧 Enhanced logging for MCP operations

781
oai.py

File diff suppressed because it is too large Load Diff