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.0.0.tar.gz (62.4 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.0.0-py3-none-any.whl (67.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for alan_terminal_ai-0.0.0.tar.gz
Algorithm Hash digest
SHA256 c47f491e66508690fcf69c25988734371b20d4aaaa5748bb770c44242fd1521c
MD5 a2dc3dea572698cc5731c32a3d7295de
BLAKE2b-256 00f1741bdeef98433189dbe56934da3bf24ddf971c552b7ae1a4ae0c6c5611c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for alan_terminal_ai-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a2416998efac445ff26971fbc130490b9ca655a44a49066e14199edff3903a2
MD5 52185327f2c9bf7a4da8b29c6a9c71e7
BLAKE2b-256 d15e69cb17c110c2d0bb40f8601b038cb80276c5c49bdf09e0022bc8bdea6c80

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