Natural language Linux terminal assistant powered by Ollama
Project description
๐ค ShellAI
Natural language Linux terminal assistant powered by Ollama
Turn plain English into safe, confirmed shell commands โ entirely local, zero cloud dependency.
$ ai find files larger than 1GB
โ Request: find files larger than 1GB
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ find . -type f -size +1G โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Execute? [y/N] y
./Downloads/ubuntu.iso
./Videos/rawfootage.mp4
โจ Features
| Feature | Details |
|---|---|
| ๐ค Natural language input | Type what you want, get a shell command |
| ๐ก๏ธ Safety filter | Blocks rm -rf /, fork bombs, disk wipes, and more |
| โ ๏ธ Risk levels | Commands rated safe / medium / high โ risky ones flagged automatically |
| ๐ Explain mode | --explain any command in plain English |
| ๐ History log | All requests and outcomes saved locally |
| ๐จ Colored output | Clean, readable terminal UI |
| โ๏ธ Configurable | Switch models, URL, and behaviour with ai --set |
| ๐ฆ Zero dependencies | Pure Python stdlib โ no requests, no click |
| ๐ 100% local | Nothing leaves your machine |
๐ Requirements
- Linux (tested on Ubuntu 22.04+, Arch, Fedora)
- Python โฅ 3.10
- Ollama running locally
๐ Installation
Option 1 โ pip (recommended)
pip install shellai
Option 2 โ development install (editable)
git clone https://github.com/yourusername/shellai
cd shellai
pip install -e ".[dev]"
Pull a model
ollama pull qwen2.5:7b # default โ fast, good quality
# or
ollama pull deepseek-coder # great for system/dev tasks
Start Ollama
ollama serve
๐ฎ Usage
Translate natural language โ shell command
ai find duplicate files
ai compress this folder
ai show running docker containers
ai install nginx
ai show disk usage by folder
ai monitor CPU and memory
ai list all open ports
Explain a command
ai --explain tar -czvf backup.tar.gz ./myfolder
ai --explain find . -name "*.log" -mtime +7 -delete
Manage history
ai --history # show last 20 commands
ai --clear-history # wipe history
Model management
ai --models # list available Ollama models
ai --model deepseek-coder "..." # use a different model for one request
ai --set model deepseek-coder:6.7b # change default model permanently
Configuration
ai --config # show all settings
ai --set model qwen2.5:7b
ai --set ollama_url http://192.168.1.5:11434
ai --set timeout 180
ai --set stream_explain true
๐ก๏ธ Safety System
Commands are classified into four risk levels:
| Level | Examples | Behaviour |
|---|---|---|
| โ safe | ls, df, ps, grep |
Confirm โ execute |
| ๐ก medium | rm file.txt, systemctl stop |
Warn + explain + confirm |
| ๐ high | rm -rf ~/dir, curl โฆ | bash |
Warn prominently + explain + confirm |
| ๐ด critical | rm -rf /, fork bomb, mkfs, dd wipe |
Blocked โ never executed |
Patterns detected include:
- Recursive root deletion (
rm -rf /) - Disk format (
mkfs) - Disk wipe via
dd - Fork bomb
:(){ :|:& };: - Base64 obfuscated eval tricks
- Pipe-to-shell downloads (
curl โฆ | bash) - System shutdown/reboot
โ๏ธ Configuration Reference
Config is stored in ~/.config/shellai/config.json.
| Key | Default | Description |
|---|---|---|
ollama_url |
http://localhost:11434 |
Ollama API base URL |
model |
qwen2.5:7b |
Default Ollama model |
timeout |
120 |
Seconds to wait for Ollama response |
history_limit |
500 |
Max entries kept in history |
stream_explain |
true |
Stream tokens when explaining |
confirm_safe |
true |
Ask confirmation for safe commands |
max_retries |
2 |
LLM retry attempts on bad output |
๐ Project Structure
shellai/
โโโ shellai/
โ โโโ __init__.py # version
โ โโโ cli.py # entry point & sub-commands
โ โโโ ollama_client.py # Ollama REST API client
โ โโโ safety.py # command safety filter
โ โโโ executor.py # subprocess runner
โ โโโ history.py # JSONL history log
โ โโโ display.py # colours & terminal UI
โ โโโ prompts.py # LLM prompt templates
โ โโโ config.py # config load/save
โโโ tests/
โ โโโ test_safety.py
โ โโโ test_cli.py
โโโ pyproject.toml
โโโ setup.py
โโโ LICENSE
โโโ README.md
๐ฌ Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Lint
ruff check shellai/
# Type-check
mypy shellai/
# Build for PyPI
python -m build
๐ฆ Publishing to PyPI
# Install build tools
pip install build twine
# Build
python -m build
# Upload to TestPyPI first
twine upload --repository testpypi dist/*
# Upload to PyPI
twine upload dist/*
๐บ๏ธ Roadmap
- Shell completion (bash/zsh/fish)
- Plugin system for custom safety rules
-
--dry-runflag (generate but never execute) -
--pipemode:echo "find large files" | ai - Multi-step task chaining
- Context awareness (detect OS, installed tools)
- Interactive REPL mode (
ai shell) - Support for remote Ollama instances
๐ License
MIT โ see LICENSE
๐ Credits
Built on Ollama โ local LLM inference made easy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qwenshell-0.2.0.tar.gz.
File metadata
- Download URL: qwenshell-0.2.0.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc04c6294ae3e1b8ce8fef697acec04f1be9a157df98c8f413bfabd3df2437e
|
|
| MD5 |
b42086c7820b01f9a58e9b902de19a0b
|
|
| BLAKE2b-256 |
24fe384cdab0d419e09cd592f5d7cbd97f3b17f65aaca0d5a7f8e66630074edf
|
File details
Details for the file qwenshell-0.2.0-py3-none-any.whl.
File metadata
- Download URL: qwenshell-0.2.0-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70c757018ff72626256c9c3fe61df90973c48de92b011ff1686b99f49d2d1fea
|
|
| MD5 |
e5cb206808a9a6e2a3997e3ad4810ce2
|
|
| BLAKE2b-256 |
17bbc30c4179a8c81d6c282ef37a041d348ea660c5157b1384b08e1f5eaa3eac
|