A powerful Node.js CLI tool that converts natural language descriptions into shell commands using multiple AI providers.
╔══════════════════════════════════════════════════════════════╗
║ ╔═══╗ ╔═══╗ ╔═══╗ ╔═══╗ ╔═══╗ ╔═══╗ ╔═══╗ ╔═══╗ ║
║ ║ N ║ ║ L ║ ║ S ║ ║ H ║ ║ E ║ ║ L ║ ║ L ║ ║ ! ║ ║
║ ╚═══╝ ╚═══╝ ╚═══╝ ╚═══╝ ╚═══╝ ╚═══╝ ╚═══╝ ╚═══╝ ║
╚══════════════════════════════════════════════════════════════╝
🤖 Convert natural language to shell commands with AI
🚀 Multi-provider support: OpenAI, Anthropic, Google, Ollama
🛡️ Built-in safety filters and command history
- 🤖 Multi-AI Support: Choose from OpenAI GPT, Anthropic Claude, Google Gemini, or Ollama
- 🛡️ Safety First: Built-in safety filters to prevent dangerous commands
- 📝 Command History: Tracks your command history locally with timestamps
- 🎨 Beautiful UI: Colored output, spinners, and ASCII art for better UX
- ⚡ Fast: Optimized prompts for quick responses
- 🔍 Explanations: Get detailed explanations of what commands do
- 🧪 Dry Run: Test commands without executing them
- 🎯 Setup Wizard: Interactive setup for selecting providers and API keys
- 📊 Command Confirmation: Review and confirm commands before execution
- 🗑️ Clean Uninstall: Safe removal of configuration and history files
npm install -g nlshellnpm install nlshell
npx nlshell-
Install the package:
npm install -g nlshell
-
Run the setup wizard:
nlshell --setup
-
Start using it:
nlshell "list all files in current directory"
# Convert natural language to shell command
nlshell "list all files in current directory"
# With explanation
nlshell "show disk usage" --explain
# Dry run - show command without executing
nlshell "list git branches" --dry-runnlshell [options] <query>
Options:
-V, --version output the version number
-h, --help display help for command
-e, --explain explain what the command does
-d, --dry-run show command without executing
-s, --setup run interactive setup wizard
--history show command history
--uninstall remove configuration and history files| Natural Language | Generated Command |
|---|---|
| "list all files in current directory" | ls -la |
| "find all python files" | find . -name '*.py' |
| "show disk usage" | df -h |
| "list all git branches sorted by date" | git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ |
| "check system memory" | free -h |
| "find files modified today" | find . -mtime -1 |
| "compress all jpg files" | tar -czf images.tar.gz *.jpg |
NLShell supports multiple AI providers:
- Model: GPT-4 or GPT-3.5-turbo
- Setup: Requires OpenAI API key
- Best for: General command generation
- Model: Claude-3-Sonnet or Claude-3-Haiku
- Setup: Requires Anthropic API key
- Best for: Detailed explanations and reasoning
- Model: Gemini Pro
- Setup: Requires Google API key
- Best for: Creative command solutions
- Models: Any Ollama model (llama2, codellama, etc.)
- Setup: Requires Ollama running locally
- Best for: Privacy and offline use
Run the interactive setup wizard to configure your preferred AI provider:
nlshell --setupThe wizard will:
- Let you choose your preferred AI provider
- Guide you through API key setup
- Test the connection
- Save your configuration
Configuration is stored in ~/.nlshell-config.json:
{
"provider": "openai",
"apiKey": "your-api-key-here",
"model": "gpt-4"
}You can also set API keys via environment variables:
OPENAI_API_KEY: For OpenAIANTHROPIC_API_KEY: For AnthropicGOOGLE_API_KEY: For Google
The tool includes comprehensive safety filters that block dangerous commands:
rm -rfoperationsddcommands- System shutdown/reboot commands
- File system operations (
mkfs,fdisk, etc.) - Dangerous permission changes
- Wildcards with root directories
- Fork bombs and other malicious patterns
Command history is stored in ~/.nlshell-history.json and includes:
- Original natural language query
- Generated shell command
- Timestamp
- Provider used
View your history:
nlshell --historyTo completely remove NLShell and all its data:
nlshell --uninstallThis will:
- Remove the global package
- Delete configuration files
- Clear command history
- Clean up all traces
nlshell/
├── index.js # CLI entry point
├── package.json # Dependencies and metadata
├── src/
│ ├── cli.js # Main CLI logic
│ ├── ai-shell.js # AI integration and command execution
│ ├── config.js # Configuration management
│ └── history.js # Command history management
├── docs/ # Documentation
├── .github/ # GitHub templates and workflows
└── README.md # This file
# Test basic functionality
nlshell "list files" --dry-run
# Test explanation feature
nlshell "show disk usage" --explain --dry-run
# Test setup wizard
nlshell --setup-
"API key not found"
- Run
nlshell --setupto configure your API key - Or set the appropriate environment variable
- Run
-
"Command execution failed"
- Check if the command is valid for your system
- Some commands may require specific tools to be installed
-
"This command may be dangerous"
- The safety filter detected a potentially dangerous command
- Review the command carefully before proceeding
-
"Provider not available"
- Ensure your chosen AI provider is properly configured
- Check your API key and internet connection
# Show help
nlshell --help
# Show version
nlshell --versionWe welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/ai-shell.git - Install dependencies:
npm install - Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test:
npm start "test command" - Commit your changes:
git commit -m 'Add amazing feature' - Push to your fork:
git push origin feature/amazing-feature - Open a Pull Request
- Session Memory: Remember context across multiple commands
- Multi-step Reasoning: Break complex tasks into steps
- Learning Mode: Learn from user corrections and preferences
- Autonomous Decision Making: Execute safe commands automatically
- Multi-agent Collaboration: Use multiple AI providers for complex tasks
- ✅ Multi-provider AI support
- ✅ Setup wizard
- ✅ Command history
- ✅ Safety filters
- ✅ Beautiful UI
- 🔄 Enhanced error handling
- 🔄 More AI providers
- 🔄 Plugin system
MIT License - see LICENSE file for details.
This tool is provided as-is. Always review generated commands before execution. The safety filters are not foolproof and should not be relied upon as the only safety measure. Use at your own risk.
Made with ❤️ by the NLShell community