8 Commits

Author SHA1 Message Date
a0ed0eaaf0 Fixed bug in cost display and handling 2026-01-26 11:39:42 +01:00
9a76ce2c1f Fixed bug in cost display and handling 2026-01-26 11:16:39 +01:00
106ef676e2 Updated to RC1 2026-01-15 10:13:49 +01:00
8c49339452 Minor bug fixes 2026-01-08 15:00:59 +01:00
8a113a9bbe Fixed some regex for files 2026-01-08 13:12:17 +01:00
c305d5cf49 More bugfixes 2026-01-07 11:09:13 +01:00
2c9f33868e More bugfixes 2026-01-07 09:58:58 +01:00
d4f1a1c6a4 Fixed bug in ctrl+c handling during response streaming 2026-01-07 08:01:33 +01:00
2 changed files with 1037 additions and 85 deletions

109
README.md
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
- 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
- Read-only access (no data modification possible)
- Schema inspection (tables, columns, indexes)
@@ -39,6 +47,8 @@ oAI is a feature-rich command-line chat application that provides an interactive
- 🔒 **Security Features**:
- Explicit folder/database approval required
- System directory blocking
- Write mode OFF by default (non-persistent)
- Delete operations always require user confirmation
- Read-only database access
- SQL injection protection
- Query timeout (5 seconds)
@@ -101,24 +111,10 @@ Download platform-specific binaries:
# Extract and install
unzip oai_vx.x.x_mac_arm64.zip # or `oai_vx.x.x-linux-x86_64.zip`
chmod +x oai
mkdir -p ~/.local/bin
mkdir -p ~/.local/bin # Remember to add this to your path. Or just move to folder already in your $PATH
mv oai ~/.local/bin/
```
### Option 3: Build Your Own Binary
```bash
# Install build dependencies
pip install -r requirements.txt
pip install nuitka ordered-set zstandard
# Run build script
chmod +x build.sh
./build.sh
# Binary will be in dist/oai
cp dist/oai ~/.local/bin/
```
### Alternative: Shell Alias
@@ -147,13 +143,18 @@ oai
You> /model
# Enable MCP for file access
You> /mcp enable
You> /mcp on
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> 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
You> /mcp add db ~/myapp/data.db
You> /mcp db 1
@@ -167,7 +168,7 @@ You> /mcp db 1
**Setup:**
```bash
/mcp enable # Start MCP server
/mcp on # Start MCP server
/mcp add ~/Projects # Grant access to folder
/mcp add ~/Documents # Add another folder
/mcp list # View all allowed folders
@@ -181,16 +182,26 @@ You> /mcp db 1
"What's in my Documents folder?"
```
**Available Tools:**
**Available Tools (Read-Only):**
- `read_file` - Read complete file contents
- `list_directory` - List files/folders (recursive optional)
- `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:**
- ✅ Automatic .gitignore filtering
- ✅ Automatic .gitignore filtering (read operations only)
- ✅ Skips virtual environments (venv, node_modules)
- ✅ Handles large files (auto-truncates >50KB)
- ✅ 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
@@ -224,13 +235,41 @@ You> /mcp db 1
- ✅ WHERE, GROUP BY, HAVING, ORDER BY, LIMIT
- ❌ 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
```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 db <number> # Switch to database mode
/mcp gitignore on # Enable .gitignore filtering (default)
/mcp write on|off # Enable/disable write mode
/mcp remove 2 # Remove folder/database by number
```
@@ -252,9 +291,9 @@ You> /mcp db 1
### MCP Commands
```
/mcp enable Start MCP server
/mcp disable Stop MCP server
/mcp status Show comprehensive status
/mcp on Start MCP server
/mcp off Stop MCP server
/mcp status Show comprehensive status (includes write mode)
/mcp add <folder> Add folder for file access
/mcp add db <path> Add SQLite database
/mcp list List all folders
@@ -263,6 +302,8 @@ You> /mcp db 1
/mcp files Switch to file mode
/mcp remove <num> Remove folder/database
/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
@@ -370,7 +411,11 @@ PDF (models with document support)
- ✅ Database opened in `mode=ro`
### 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
- ✅ Build artifact filtering
- ✅ Maximum file size (10 MB)
@@ -458,14 +503,19 @@ ls -la database.db
## Version History
### v2.1.0-beta (Current)
### v2.1.0-RC1 (Current)
-**NEW**: MCP (Model Context Protocol) integration
-**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**: Dual mode support (Files & Database)
-**NEW**: .gitignore filtering
-**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
- 🔧 Improved error handling for tool calls
- 🔧 Enhanced logging for MCP operations
@@ -508,6 +558,7 @@ Full license: https://opensource.org/licenses/MIT
**Rune Olsen**
- Homepage: https://ai.fubar.pm/
- Blog: https://blog.rune.pm
- Project: https://iurl.no/oai
@@ -527,3 +578,7 @@ Contributions welcome! Please:
---
**Star ⭐ this project if you find it useful!**
---
Did you really read all the way down here? WOW! You deserve a 🍾 🥂!

987
oai.py

File diff suppressed because it is too large Load Diff