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.
- π Documentation
- π Report Issues
- π‘ Feature Requests
- π€ Contributing
Made with β€οΈ by the NLShell community