Skip to main content

AI-powered terminal assistant that converts natural language to safe shell commands using Ollama

Project description

🖥️ Alan – Terminal Command Assistant (Powered by Ollama)

Alan is your friendly AI-powered terminal assistant that turns natural language requests into safe, executable shell commands using Ollama.


🚀 Features

  • Natural language to terminal commands
    Example: alan please list directory filesls
  • Smart command tracking and learning
    Alan learns from your preferences to improve suggestions
  • Confidence scoring for command suggestions
  • Safety checks for dangerous commands
  • Supports multiple Ollama models
  • Multi-step operation support
  • Command statistics and insights
  • Confirmation before execution

📦 Requirements

  • Python 3.7+
  • Ollama installed and running
    brew install ollama
    ollama serve
    
  • At least one supported Ollama model (default: qwen2.5:0.5b)

    ollama pull qwen2.5:0.5b
    

🔧 Installation

  1. Download the alan script

    curl -O https://raw.githubusercontent.com/ankit0305/alan/main/alan
    chmod +x alan
    
  2. Move to your local bin directory

    mkdir -p ~/.local/bin
    mv alan ~/.local/bin/
    
  3. Add to your PATH (if not already)

    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    

    (Use .bashrc if you're on bash)


💡 Usage

alan please [your request]
python3 alan.py please list directory files

Examples

alan please list directory files
alan please show current directory
alan please find files with .txt extension
alan please show disk usage
alan please check running processes

📜 Options

alan --help     # Show help message
alan --version  # Show version info
alan stats      # Show command tracking statistics

🧠 Smart Learning & Tracking

Alan automatically tracks your command preferences to improve future suggestions:

Command Tracking Features

  • Acceptance/Rejection Tracking: Learns which commands you accept or reject
  • Confidence Scoring: Shows confidence levels for suggestions based on your history
  • Similar Command Suggestions: Shows previously accepted similar commands
  • Usage Statistics: Track your most used command types and success rates
  • Pattern Analysis: Identifies patterns in your command preferences

View Your Statistics

alan stats

This shows:

  • Total suggestions made
  • Acceptance rate percentage
  • Most used command types
  • Recent activity summary
  • Actionable insights for improvement

Data Storage

  • Command history is stored in command_history.json
  • Data includes timestamps, user requests, suggested commands, and outcomes
  • Automatic cleanup of old data (configurable)
  • Export functionality for data analysis

⚠️ Safety

Alan will:

  • Reject dangerous commands (e.g., rm -rf /)
  • Ask for confirmation before running anything
  • Display the suggested command first

You can review and modify the command before running it.

🛠 How It Works

  1. You type a natural language request with alan please.
  2. Alan sends the request to your local Ollama instance.
  3. The AI model returns a single shell command.
  4. Alan checks if it's safe and asks for your confirmation.
  5. If approved, it runs the command and shows the output.

🧩 Customization

Configuration File

Create ~/.alan_config.json to customize Alan's behavior:

{
  "tracking": {
    "enabled": true,
    "show_confidence": true,
    "show_similar_commands": true
  },
  "display": {
    "show_system_info": true,
    "use_emojis": true,
    "verbose_output": false
  },
  "safety": {
    "enable_safety_checks": true,
    "prompt_for_dangerous_commands": true
  }
}

Advanced Customization

  • Default model: Change the models_to_try list in the script to use your preferred Ollama models.
  • Dangerous commands list: Update dangerous_patterns in the is_safe_command() function.
  • Tracking settings: Adjust command tracking behavior in the config file.

📊 Example Output

When you use Alan, you'll see helpful information:

$ alan please list files
🖥️  System: macOS (unix)
🔍 Using model: gemma3:4b
💡 Suggested (macOS): ls -la
🎯 High confidence (85%)
💭 Similar commands you've accepted:
   • ls -l
Execute? [y/N]: y
⚡ Running: ls -la
----------------------------------------
total 48
drwxr-xr-x  8 user  staff   256 Jan 29 12:36 .
drwxr-xr-x  3 user  staff    96 Jan 29 12:30 ..
-rw-r--r--  1 user  staff  1234 Jan 29 12:35 alan.py
-rw-r--r--  1 user  staff   567 Jan 29 12:36 README.md
----------------------------------------
✅ Command executed successfully
💡 Tip: Use 'alan copy' to copy the output to clipboard

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

alan_terminal_ai-0.2.7.tar.gz (53.7 kB view details)

Uploaded Source

Built Distribution

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

alan_terminal_ai-0.2.7-py3-none-any.whl (65.1 kB view details)

Uploaded Python 3

File details

Details for the file alan_terminal_ai-0.2.7.tar.gz.

File metadata

  • Download URL: alan_terminal_ai-0.2.7.tar.gz
  • Upload date:
  • Size: 53.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for alan_terminal_ai-0.2.7.tar.gz
Algorithm Hash digest
SHA256 41ab24f176bcdf8f0ceb935587934f306d9458abf54f322b8c89015eb0fc966f
MD5 b3c5355969012dd6ecef0a30473741a9
BLAKE2b-256 2dac9957ee021c6d4067afd5f00813480ab5fb5645124f0a8da1fbda4be18d04

See more details on using hashes here.

File details

Details for the file alan_terminal_ai-0.2.7-py3-none-any.whl.

File metadata

File hashes

Hashes for alan_terminal_ai-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 11de25e03c3d83bb75682d9ccc62bf18cb0de45cc140fc37bc523234b499fe56
MD5 43e30d9a7a5ceb1c2aa3d1d0544bdf26
BLAKE2b-256 5403e2654ce2db39846e6fd56a5248f44dc3197a12218a7093ec0b3496bbc76b

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