Skip to main content

AI-powered CLI assistant for shell command generation

Project description

How-to CLI

An AI-powered command-line interface assistant that instantly translates natural language requests into precise, executable shell commands.

Features

  • 🧠 Natural Language Processing: Convert plain English descriptions into accurate shell commands
  • 🔒 Safety First: All generated commands require explicit confirmation before execution
  • 🔄 Multi-Provider Support: Works with Google Gemini, OpenAI, and Groq APIs
  • 💾 Persistent Configuration: Settings saved to $HOME/.howto-cli-ai/config.json
  • 🌍 Cross-Platform: Generates compatible commands for Linux, macOS, and Windows
  • 🎯 Smart Context Detection: Automatically detects operating system and shell environment

Installation

pip install howto-cli-ai

Quick Start

  1. Setup Your Provider:

    how setup
    

    The interactive setup wizard will guide you through:

    • Selecting your preferred AI provider
    • Configuring API keys securely
    • Testing connectivity
    • Setting your default provider
  2. Generate Commands (no quotes needed):

    how to list all files in current directory
    how to find all Python files larger than 1MB
    how to shutdown after 30 min
    how to create backup of home directory
    

Configuration

The how setup command provides an enhanced interactive wizard for:

  • Provider Selection: Choose from Google Gemini, OpenAI, or Groq with descriptions
  • API Key Management: Securely configure API keys in persistent config file
  • Provider Switching: Change your default provider at any time
  • Connection Testing: Verify API connectivity before using

Persistent Configuration

Configuration is automatically saved to $HOME/.howto-cli-ai/config.json:

  • API Keys: Securely stored in JSON format with fallback to environment variables
  • Default Provider: Your chosen provider is remembered across sessions
  • Multiple Providers: Configure all three providers and switch between them easily
  • Backward Compatible: Existing environment variable workflows continue to work
# Location of config file
$HOME/.howto-cli-ai/config.json

# Example config structure
{
  "default_provider": "openai",
  "api_keys": {
    "openai": "sk-your-api-key"
  }
}

Safety

  • Mandatory Confirmation: Every generated command requires explicit approval
  • ⚠️ Destructive Operation Detection: Potentially harmful commands are flagged with warnings
  • 🔐 Secure Key Storage: API keys stored in user home directory with proper permissions
  • 🔄 Smart Fallbacks: Graceful error handling and retry mechanisms

Supported Providers

🟠 Google Gemini

  • Models: gemini-2.5-pro (advanced), gemini-2.5-flash (default)
  • Features: Fast response times, strong reasoning capabilities

🟢 OpenAI

  • Models: gpt-4, gpt-4-turbo, gpt-3.5-turbo
  • Features: Highly capable general-purpose AI, excellent code generation

🔴 Groq

  • Models: llama-3.3-70b-versatile, llama-3.1-70b-versatile, mixtral-8x7b-32768
  • Features: Ultra-fast inference, cost-effective option

Examples

# Basic file operations (no quotes needed)
how to list all JPEG files in current directory

# Complex operations with multiple steps
how to find files larger than 100MB and move them to archive

# System administration
how to check disk usage and show top 10 largest files

# Time-based operations
how to shutdown after 30 min
how to remind me to take a break in 15 minutes

# Development tasks
how to start a Python HTTP server on port 8000
how to kill all processes running on port 3000

Advanced Usage

# Switch providers without losing API keys
how setup  # Re-run setup and choose different provider

# Check current configuration
cat $HOME/.howto-cli-ai/config.json

# Use environment variables (alternative to config file)
export OPENAI_API_KEY="sk-your-key"
export HOW_DEFAULT_PROVIDER="openai"
how to list docker containers

# Temporary provider override
GROQ_API_KEY="gsk-your-key" how to optimize system performance

Configuration File

The configuration file is automatically created and managed:

# View your current configuration
cat ~/.howto-cli/config.json

# Manual configuration (optional)
{
  "default_provider": "gemini",
  "providers": {
    "gemini": {
      "api_key_env_var": "GEMINI_API_KEY",
      "default_model": "gemini-2.5-flash",
      "available_models": ["gemini-2.5-pro", "gemini-2.5-flash"]
    }
  },
  "api_keys": {
    "gemini": "your-gemini-api-key"
  }
}

Troubleshooting

Provider Not Working

# Test connectivity
how setup  # Re-run to test your selected provider

# Check API key
echo $GEMINI_API_KEY  # Verify your environment variable

# Check config
cat ~/.howto-cli-ai/config.json  # Verify persistent configuration

Common Issues

  • "No API keys configured": Run how setup to configure your provider
  • "Provider failed": Check your API key and network connection
  • "Config file corrupted": Delete ~/.howto-cli-ai/config.json and re-run setup

Development

Setup Development Environment

# Clone and install
git clone https://github.com/yourusername/howto-cli.git
cd howto-cli
# For local development (cloning from source)
pip install -e ".[dev]"

# For regular installation from PyPI
pip install howto-cli-ai

Development Commands

# Run tests with coverage
pytest --cov=howto_cli

# Code formatting
black howto_cli/
ruff format howto_cli/

# Linting and type checking
ruff check howto_cli/
mypy howto_cli/

# Run CLI locally
python -m howto_cli.cli setup
python -m howto_cli.cli to "list all files"

Project Structure

src/howto_cli/
├── cli.py              # Main CLI interface with commands
├── core/
│   ├── config.py       # Configuration management
│   └── command_generator.py  # Command generation logic
├── ai/
│   ├── gateway.py      # AI provider abstraction
│   └── providers.py    # Specific provider implementations
└── models/
    └── command.py      # Pydantic models for commands

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and ensure tests pass
  4. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Typer for the CLI interface
  • Uses Pydantic for data validation
  • Powered by leading AI providers: Google, OpenAI, and Groq

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

howto_cli_ai-0.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

howto_cli_ai-0.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file howto_cli_ai-0.1.0.tar.gz.

File metadata

  • Download URL: howto_cli_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for howto_cli_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ff98ad4097c5d172eedc25f54b9e7d714f607f1f242dc7c452169ceb19d6da60
MD5 5205f8f3752b35e30f9371d30aee9c76
BLAKE2b-256 eaaf70fad61af43fccdc00d2876572bb93d5358b68f4daab5c3814fe31cb7535

See more details on using hashes here.

File details

Details for the file howto_cli_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: howto_cli_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for howto_cli_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27ab002a9cab72fd614364f37ad5037f1e4909be742dced1c7450195bb39faf6
MD5 e2d066bc73c06e0c3a1b2d275501a381
BLAKE2b-256 26e93c099eb91e99f6a33e1bf9be940839eab66af270176186766c93bec22ca6

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