command-gpt
v1.0.1
Published
A CLI tool that converts plain English into shell commands using AI
Downloads
25
Maintainers
Readme
ShellAI (s)
Convert plain English into shell commands — powered by AI.
$ s "find all files larger than 100MB"
╭─ Command ──────────────────────────────╮
│ find . -size +100M │
╰────────────────────────────────────────╯
Explains Finds all files larger than 100MB in the current directory
Alternatives:
• find . -size +100M -type f
• du -ah . | sort -rh | head -20
Run it? › [y] run [n] cancel [c] copyInstall
# Clone and install globally
cd shellAi
npm install
npm run build
npm link
# After install, run setup
s --setupOr install from npm (once published):
npm install -g shellai
s --setupSetup
Run the interactive setup to configure your API key:
s --setupYou'll be prompted to:
- Choose your LLM provider (Groq or OpenAI)
- Enter your API key
- Set shell preferences
Getting a Free Groq API Key
- Go to console.groq.com
- Sign up for a free account
- Navigate to API Keys in the sidebar
- Click Create API Key
- Copy the key and paste it during
s --setup
Groq provides free access to Llama 3.3 70B — it's fast and works great for command generation.
Switching to OpenAI
If you prefer to use OpenAI:
s --setup
# Select "OpenAI (gpt-4o-mini)" as your provider
# Enter your OpenAI API keyUsage Examples
# Find large files
s "find all files larger than 100MB"
# Kill a process by port
s "kill the process running on port 3000"
# Compress a folder
s "compress this folder into a zip"
# Disk usage
s "show disk usage sorted by size"
# Git operations
s "undo the last commit but keep the changes"How It Works
- You type a command description in plain English
- ShellAI detects your OS, shell, and working directory
- It sends your request to an LLM (Groq or OpenAI) with full context
- The LLM returns a precise shell command with an explanation
- You choose to run, cancel, or copy the command
Safety Features
- Dangerous command warnings: Commands that delete or modify files are flagged with a red warning
- Double confirmation for
rm -rf: Extra safety for destructive deletions - Sudo detection: Yellow warning when commands require elevated privileges
- No auto-sudo: Commands never include
sudounless you explicitly ask
Configuration
Config is stored at ~/.shellai/config.json:
{
"groqApiKey": "gsk_...",
"openaiApiKey": "",
"defaultProvider": "groq",
"shell": "auto",
"confirmBeforeRun": true
}View your current config:
s --configCommands
| Command | Description |
|---------|-------------|
| s "your request" | Convert English to a shell command |
| s --setup | Configure API keys and preferences |
| s --config | Show current configuration |
| s --help | Show help information |
| s --version | Show version number |
Tech Stack
- TypeScript + Node.js 18+
- Groq API (primary, free) — Llama 3.3 70B
- OpenAI API (fallback) — GPT-4o-mini
- Commander — CLI argument parsing
- Inquirer — Interactive prompts
- Chalk — Colored terminal output
- Ora — Loading spinners
- Execa — Safe command execution
- Clipboardy — Clipboard support
License
MIT
