CmdAssist is a PowerShell module that provides AI-powered command line assistance. It helps users by suggesting appropriate commands based on natural language prompts using various Large Language Models (LLMs).
- π€ Multiple AI Providers: Support for OpenAI, Azure OpenAI, Claude, Llama, Google Gemini, and DeepSeek
- β‘ PowerShell Integration: Native PowerShell cmdlet with proper parameter support
- π‘οΈ Safety First: Confirmation prompts before executing potentially dangerous commands
- π Clipboard Support: Copy commands to clipboard without execution
- π§ Context Aware: Uses current working directory and system information
- π Confidence Scoring: AI responses include confidence levels
- .NET 8.0 SDK or later
- PowerShell 7.4 or later
- Clone the repository:
git clone https://github.com/kunalk16/cmdassist.git
cd cmdassist- Build the project:
dotnet build- Import the module:
Import-Module ./src/CmdAssist.PowerShell/bin/Debug/net8.0/CmdAssist.psd1CmdAssist uses environment variables for API configuration. Set the appropriate variables for your chosen AI provider:
$env:OPENAI_API_KEY = "your-openai-api-key"
$env:OPENAI_MODEL = "gpt-4" # Optional, defaults to gpt-4
$env:OPENAI_ORGANIZATION = "your-org-id" # Optional$env:AZURE_OPENAI_API_KEY = "your-azure-openai-key"
$env:AZURE_OPENAI_ENDPOINT = "https://your-resource.openai.azure.com/"
$env:AZURE_OPENAI_DEPLOYMENT_NAME = "your-deployment-name"
$env:AZURE_OPENAI_API_VERSION = "2024-02-01" # Optional$env:CLAUDE_API_KEY = "your-claude-api-key"
$env:CLAUDE_MODEL = "claude-3-sonnet-20240229" # Optional$env:LLAMA_API_URL = "https://your-llama-endpoint.com"
$env:LLAMA_API_KEY = "your-api-key" # Optional, depending on your setup
$env:LLAMA_MODEL = "llama2-70b-chat" # Optional$env:GEMINI_API_KEY = "your-gemini-api-key"
$env:GEMINI_MODEL = "gemini-pro" # Optional, defaults to gemini-pro$env:DEEPSEEK_API_KEY = "your-deepseek-api-key"
$env:DEEPSEEK_API_URL = "https://api.deepseek.com/v1" # Optional
$env:DEEPSEEK_MODEL = "deepseek-chat" # Optional, defaults to deepseek-chat- OpenAI: Get your API key at platform.openai.com
- Azure OpenAI: Set up through Azure Portal
- Claude: Get API access at console.anthropic.com
- Llama: Use any Llama-compatible endpoint (Ollama, LM Studio, etc.)
- Google Gemini: Get API key at aistudio.google.com
- DeepSeek: Register at platform.deepseek.com
# Get a command suggestion with confirmation prompt
cmd-assist "list all .txt files in the current directory"
# Execute directly without confirmation
cmd-assist "create a new folder called 'documents'" -Confirm
# Use a specific AI provider
cmd-assist "show disk usage" -Provider Claude
# Enable verbose output
cmd-assist "find large files" -Verbose# File operations
cmd-assist "copy all .pdf files to a backup folder"
cmd-assist "find files modified in the last 7 days"
cmd-assist "compress the logs folder"
# System administration
cmd-assist "check system memory usage"
cmd-assist "restart the print spooler service"
cmd-assist "show network connections"
# Development tasks
cmd-assist "initialize a git repository"
cmd-assist "build a .NET project in release mode"
cmd-assist "run unit tests and show coverage"When you run a command without the -Confirm switch, CmdAssist will:
- Display the suggested command
- Show an explanation of what it does
- Ask for confirmation with options:
- Yes: Execute the command
- No: Cancel execution
- Copy: Copy the command to clipboard without executing
Prompt(Position 0, Mandatory): The natural language description of what you want to accomplishConfirm(Switch): Execute the command without confirmation promptProvider(Optional): Specify AI provider (OpenAI, AzureOpenAI, Claude, Llama, Gemini, DeepSeek)Verbose(Switch): Enable verbose output for debugging
- Confirmation Prompts: By default, all commands require user confirmation
- Confidence Scoring: Low-confidence responses trigger additional warnings
- Context Awareness: Commands are generated with awareness of your current environment
- Error Handling: Comprehensive error handling with helpful messages
-
API Key Not Set
Error: OpenAI API key not configured. Set the OPENAI_API_KEY environment variable.Solution: Set the appropriate environment variable for your chosen provider.
-
Network Connection Issues
Error: API request failed: UnauthorizedSolution: Verify your API key and network connection.
-
Module Import Errors
Import-Module: Could not load file or assemblySolution: Ensure .NET 8.0 runtime is installed and try rebuilding the project.
cmd-assist "your prompt" -Verbosecmdassist/
βββ src/
β βββ CmdAssist.PowerShell/
β βββ Cmdlets/ # PowerShell cmdlet implementations
β βββ Services/ # AI service implementations
β βββ Models/ # Data models and DTOs
β βββ CmdAssist.psd1 # PowerShell module manifest
β βββ CmdAssist.PowerShell.csproj
βββ Directory.Build.props # Common build properties
βββ Directory.Packages.props # Package version management
βββ global.json # .NET SDK version
βββ cmdassist.sln # Solution file
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
dotnet testdotnet build -c ReleaseThis project is licensed under the MIT License. See the LICENSE file for details.
- π Documentation
- π Issues
- π¬ Discussions
-Confirm switch. CmdAssist is a tool to assist with command generation, but you remain responsible for the commands you choose to execute.