1.0.0 • Published 4 months ago

ai2cli v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

ai2cli

CLI utility to convert English text to shell commands using an LLM.

npm version License: MIT

Description

ai2cli is a command-line utility that converts natural language queries into shell commands using various LLM providers. It helps you generate complex commands without having to remember syntax or read through documentation.

Features

  • Convert English descriptions to shell commands
  • Multiple AI provider support (OpenAI, Anthropic, Google, DeepSeek, Groq, Mistral, XAI, Ollama)
  • Interactive command refinement
  • Command clarification when information is missing
  • Save and refine scripts
  • Command execution with confirmation
  • Command explanation and breakdown
  • Safety checks for destructive commands

Installation

# Install globally using npm
npm install -g ai2cli

# or using yarn
yarn global add ai2cli

# or using pnpm
pnpm add -g ai2cli

Setup

On first run, ai2cli will create a configuration file at ~/.ai2cli. You will need to add your API keys to this file.

You can also enter setup mode:

ai2cli --setup

Basic Usage

# Basic command generation
ai2cli "find all JavaScript files modified in the last week"

# Generate a script instead of a command
ai2cli --script "backup all my markdown files, compress them, and upload to my S3 bucket"

# Use a specific model
ai2cli --model openai/gpt-4o "convert all png images in this directory to jpeg"

# Refine existing scripts
ai2cli --refine-scripts

Configuration

Configuration is stored in ~/.ai2cli and follows this format:

{
  "defaultModel": "openai/gpt-4o",
  "models": ["openai/gpt-4o", "anthropic/claude-3.7", "ollama/llama3.2"],
  "scriptsDir": "~/.ai2cli-scripts",
  "providers": {
    "openai": {
      "apiKey": "YOUR_OPENAI_API_KEY",
      "baseURL": "https://api.openai.com"
    },
    "anthropic": {
      "apiKey": "YOUR_ANTHROPIC_API_KEY",
      "baseURL": "https://api.anthropic.com"
    }
  }
}

Supported LLM Providers

  • OpenAI (GPT-4o, GPT-4, GPT-3.5 Turbo, etc.)
  • Anthropic (Claude 3.7, Claude 3.5, Claude 3 Opus, etc.)
  • Google (Gemini models)
  • Deepseek
  • Groq
  • Mistral
  • XAI (Grok)
  • Ollama (local models)

Command Line Options

  • [request...] - Natural language request for a command
  • --model <model> - Override the default model from config
  • --script - Skip command generation and go directly to script mode
  • --debug - Enable debug features
  • --refine-scripts - Select and refine an existing script from the scripts directory
  • --setup - Enter setup mode to configure or modify your ai2cli settings

License

MIT