Q&AI (WinQ) – AI Command Line Helper for Windows

Overview
A tiny console companion that turns natural-language questions into concise, shell-appropriate answers or single commands. It minimizes context switching and speeds up repetitive terminal work.

Key Features
• Detects PowerShell, Windows PowerShell, cmd.exe, and basic POSIX shells (WSL/Git Bash)  
• Lucky mode (`q l ...`) emits one ready-to-run command and types it for native Windows shells  
• WSL-aware: prints commands when injection is impossible  
• Markdown → ANSI color formatting for readable answers  
• Lightweight version check (remote text)  
• UTF-8 output with VT color support  
• Depends only on libcurl + nlohmann::json

Compatibility
• Windows 10/11 (PowerShell 5.x, PowerShell 7+, cmd.exe)  
• WSL distributions (command printed)  
• Git Bash / MSYS2 / MinGW (command printed)  
• Requires outbound HTTPS to OpenAI’s API  
• 64-bit Windows binary

Requirements
• OPENAI_API_KEY environment variable  
• libcurl-4.dll (and dependencies) beside q.exe if not statically linked  
• VT-capable console (Windows Terminal, conhost with VT enabled)

Installation
1. Place q.exe somewhere on PATH (e.g., C:\Tools\QAI).  
2. Copy libcurl-4.dll and dependent DLLs if dynamically linked.  
3. Set API key:  
   PowerShell → `$env:OPENAI_API_KEY = "sk-..."`  
   cmd.exe   → `set OPENAI_API_KEY=sk-...`  
4. Run `q.exe --help`.

Usage
• Contextual reply: `q show the total size of the Desktop folder`  
• Lucky mode command: `q l list files including hidden`  
• Shell prefix overrides detection:  
  `q bash: show current directory`  
  `q cmd: list hidden files`  
  `q powershell: compress the logs folder`

Lucky Mode Behavior
• Native Windows shells: keystrokes injected automatically.  
• WSL/POSIX shells: command printed for manual copy (pty injection unsupported).

Environment Overrides
• `Q_SHELL` forces shell (bash, cmd, pwsh, powershell, zsh, fish).  
• Prefix syntax (`bash:`, `cmd:`, `powershell:`) overrides all detection for that query.

Security & Privacy
• Sends only your prompt + system message to OpenAI.  
• No local logging unless you redirect output.  
• Avoid pasting secrets.

Limitations
• Model might return multi-line output in lucky mode (first line used).  
• Requires internet; no offline fallback.  
• Detection is heuristic—explicit prefixes win.  
• WSL command injection intentionally disabled.

Troubleshooting
• Empty output → ensure OPENAI_API_KEY is set.  
• Wrong shell syntax → add a prefix (e.g., `bash:`).  
• Missing colors → use Windows Terminal or enable VT.

Roadmap
• Optional clipboard copy for lucky mode  
• Multi-command confirmation prompt  
• Automatic Windows↔WSL path translation  
• Plugin hook for post-processing

License
Specify one (e.g., MIT) in the repo if not already.

Credits
Built with libcurl and nlohmann::json. AI responses provided by OpenAI.

Quick Summary
Q&AI = Ask → Receive shell-specific answer/command → Execute faster.

Updates: https://kervels.net/q&ai/