v6.0 - Offline Mode, Universal Shells & Self-Healing Core
🚀 ZAI Shell v6.0
The Ultimate AI-Powered Command Line Assistant with Offline Support
🌟 What's New in v6.0
This isn't just an update - it's a complete architectural overhaul. Core systems, error handling, offline capabilities, and shell integration have been completely rewritten from the ground up.
🎯 Key Highlights
- ✨ Universal Shell Support - 13 different shells across Windows, Linux, and macOS
- 🔌 Offline Mode - Run completely locally with Microsoft Phi-2 model
- 🧠 Smart Auto-Retry - Automatically tries 5 different approaches on failures
- 💾 Dual Memory System - ChromaDB vector storage + JSON fallback
- 🛡️ Advanced Safety - Built-in dangerous command protection
- ⚡ 3 Operation Modes - Normal, Eco, and Lightning modes for different use cases
🔧 Critical Under-the-Hood Improvements
🔄 Enhanced Auto-Retry Mechanism
- 5 retry attempts (upgraded from 3)
- Automatically switches to different shells and methods on failure
- Intelligent fallback strategies prevent infinite loops
🌡️ Lightning Mode Stabilization
- Fixed: Temperature 0.0 crash with
do_sample=True - Solution: Automatic temperature adjustment to 0.1 in Lightning mode
- Maintains blazing speed while preventing mathematical errors
🚩 Smart Flag Parsing
- Fixed: Flags like
--forceand-fnow work anywhere in command - Properly extracts and applies flags before command processing
- Case-insensitive flag detection
✂️ Surgical JSON Extraction
- Advanced bracket counting algorithm
- Extracts valid JSON even when AI generates extra text
- Handles code, explanations, and poetry around JSON responses
📂 Smart Path Correction
- Automatically converts relative paths like
Desktop/file.txt - Translates to actual user paths (e.g.,
C:\Users\YourName\Desktop\file.txt) - Works seamlessly across different path formats
🐚 Universal Shell Support (13 Shells)
Windows Environment
- CMD - Standard command prompt
- PowerShell - Advanced Windows management
- PWSH - Modern cross-platform PowerShell Core
- Git Bash - Linux commands on Windows (3 installation paths scanned)
- WSL - Full Ubuntu/Debian environment in Windows
- Cygwin - Unix tools for Windows (2 installation paths scanned)
Linux/macOS Environment
- Bash - Standard Linux shell
- Sh - Basic POSIX shell
- Zsh - macOS default shell
- Fish - Colorful shell with suggestions
- Ksh - Korn shell
- Tcsh - Tenex C shell
- Dash - Debian Almquist shell
ZAI automatically detects available shells and chooses the best one for each command!
🧠 AI Architecture
🔌 OFFLINE MODE
- Model: Microsoft Phi-2 (2.7B parameters)
- Hardware: Automatic GPU (CUDA) or CPU selection
- Smart Prompting: Few-shot examples prevent verbose responses
- Optimized: Token limits and repetition penalties for concise output
- First Run: Automatically downloads model (~5GB)
🌐 ONLINE MODE (Gemini API)
Normal Mode
- Model: gemini-2.5-flash
- Temperature: 0.7
- Balanced performance for everyday tasks
Eco Mode ⚡
- Model: gemini-2.5-flash-lite
- Temperature: 0.3
- Features:
- Command chaining encouraged (mkdir test && cd test)
- Maximum token efficiency
- Deterministic JSON output
Lightning Mode ⚡⚡
- Model: gemini-2.5-flash-lite
- Temperature: 0.1
- Features:
- Zero conversation, zero explanations
- Minimal JSON output only
- Skips thinking process
- Ultra-fast execution
💾 Dual Memory System
ChromaDB (Vector Memory)
- Semantic Search: Finds conversations by meaning, not just keywords
- Example: Search "calculator" finds math-related conversations even without exact word match
- Persistent: Stores across sessions
JSON Fallback
- Automatic fallback if ChromaDB isn't installed
- No crashes, seamless degradation
- Traditional conversation history storage
🛡️ Security & Safety Features
New Flag Commands
--safe / -s
Blocks dangerous commands including:
rm -rf,sudo rm,formatreboot,shutdown,mkfsdd if=,:(){:|:&};:(Fork Bomb)chmod -R 777 /, and more...
"delete all logs --safe" # Will block dangerous operations--show
Preview mode - displays actions without executing them
"create calculator app --show" # Shows plan, doesn't execute--force / -f
Skip confirmation prompts for instant execution
"install dependencies --force" # No confirmation needed🎮 Usage Examples
Basic Commands
# File operations
"create a calculator on desktop"
"write a Python web scraper to Documents"
# System analysis
"show top 5 CPU processes"
"analyze disk space and create report"
# Multi-tasking
"backup all .txt files and create a log"Mode Switching
# Permanent mode change
normal
eco
lightning
# Temporary mode (one command only)
"your command here eco"
"analyze system lightning"Network Modes
switch offline # Use local AI model
switch online # Use Gemini APIThinking Mode
thinking on # Show AI's thought process
thinking off # Hide thinking processMemory Commands
memory clear # Clear conversation history
memory show # Display recent conversations
memory search "query" # Semantic search in history📋 Requirements
Basic (Online Mode)
pip install google-generativeai coloramaFull Features
pip install google-generativeai colorama chromadb psutilOffline Mode (Additional)
pip install transformers torch accelerate🚀 Installation
- Clone the repository:
git clone https://github.com/TaklaXBR/zai-shell.git
cd zaishell- Install dependencies:
pip install -r requirements.txt- Set your API key (for online mode):
# Windows
set GEMINI_API_KEY=your_api_key_here
# Linux/Mac
export GEMINI_API_KEY=your_api_key_here- Run ZAI:
python zaishell.py💡 Pro Tips
-
Use mode overrides for specific tasks:
- Complex analysis? Try"your task normal"
- Quick commands? Try"your task lightning" -
Combine flags for maximum control:
-"risky command --safe --show"- Preview safely
-"batch operations --force"- Speed through confirmations -
Leverage offline mode for:
- No internet environments
- Privacy-sensitive operations
- Learning AI behavior locally -
Use thinking mode when:
- Debugging complex commands
- Understanding AI decision-making
- Educational purposes
🐛 Known Issues & Fixes
- ✅ Fixed: Lightning mode temperature crash
- ✅ Fixed: Flag parsing in middle of commands
- ✅ Fixed: Path resolution on Windows
- ✅ Fixed: JSON extraction from verbose AI responses
- ✅ Fixed: Auto-retry infinite loops
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
GNU Affero General Public License v3.0
⭐ Star History
If you find ZAI Shell useful, please consider giving it a star! ⭐