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.1.tar.gz (31.0 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.1-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qwenshell-0.2.1.tar.gz
  • Upload date:
  • Size: 31.0 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.1.tar.gz
Algorithm Hash digest
SHA256 ba190d61c6e8bddcf18fe86b6f90af82a397349a8920f21cc6dd9653f7fe02b5
MD5 53560b2579c704522845ad41e8b6d941
BLAKE2b-256 02ffc12e1e477b90440a38fb8d37d135f40610c89eaaa3765fd31e67191e6bdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qwenshell-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 30.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec89c12690a376a3913524e392b889b504cf6e7e180c7f4a880019bd50ba7ffd
MD5 2b481b888f13744b1429aec481f7fec4
BLAKE2b-256 6c46fcceb9b826c99f6cbc5610bfdc29b68672293c02e35b1db2925bda8d0c66

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