Skip to main content

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-run flag (generate but never execute)
  • --pipe mode: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qwenshell-0.2.2.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qwenshell-0.2.2-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file qwenshell-0.2.2.tar.gz.

File metadata

  • Download URL: qwenshell-0.2.2.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for qwenshell-0.2.2.tar.gz
Algorithm Hash digest
SHA256 41e2c95beb820a4618faa343b6a94249584db5f4d1b49c45104f88166df7317e
MD5 5091badfb61c8ecb5934fec40ad1d5bb
BLAKE2b-256 47a908f17f9c7eacbdad4a71627f8faf2d402075115fad9d260f746989f4f87c

See more details on using hashes here.

File details

Details for the file qwenshell-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: qwenshell-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for qwenshell-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05f987d4e7da8d13045e1fda65586b41deee94ef22daeba7c7d2f7099c60115a
MD5 462b0a3649cfb3579226e4012c4d200d
BLAKE2b-256 821f5b735a7c15e5b7b69dfd166f0cac531c163de3674e068af3ac2160e238ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page