PowerShell EX
by mjojo
README.md
# PowerShell EX β Advanced PowerShell for VS Code & Antigravity IDE
<div align="center">




π **The most powerful PowerShell integration for VS Code and AI-driven development**
*Created by [Vitaly Golik (mjojo)](mailto:vitaly.golik@gmail.com)*
</div>
---
## π Why PowerShell EX is Better Than Other Extensions
### vs. Official PowerShell Extension
| Feature | PowerShell EX | Official Extension |
|---------|:-------------:|:------------------:|
| **AI Agent Integration (MCP)** | β
Full support | β Not available |
| **Token-Optimised Output** | β
85β99% savings | β Not applicable |
| **Autonomous Script Execution** | β
Yes | β Manual only |
| **Real-time PSScriptAnalyzer** | β
Instant feedback | β οΈ Delayed |
| **ISE Compatibility Mode** | β
Perfect emulation | β οΈ Partial |
| **Memory Footprint** | β
Lightweight | β Heavy |
| **Startup Time** | β
< 1 second | β 3-5 seconds |
| **Native TabExpansion2** | β
Full support + cache | β
Yes |
### π― Key Advantages
1. **π° Token-Optimised for AI Agents**
Every byte returned to an AI costs money. PowerShell EX aggressively minimises output:
- ANSI escape codes stripped automatically (invisible to AI, waste tokens)
- `invoke_cmdlet` returns only meaningful fields β `Get-Process` goes from **911 KB β ~300 bytes** (β99.9%)
- Compact JSON serialisation (no pretty-print whitespace)
- Output capped at configurable `maxOutput` chars (default 4 000)
- Completions cached for 5 s β no redundant process spawns
2. **π€ AI-First Architecture**
Built from the ground up for AI agents. MCP protocol enables Antigravity's AI to write, execute, and debug PowerShell autonomously β no human intervention required.
3. **β‘ Lightning Fast**
No bloated language server. Direct PowerShell execution with minimal overhead. Extension activates in under 1 second.
4. **π Secure Execution**
Scripts are written to temp files β no shell injection possible. Input validation on all cmdlet names.
5. **π Smart Analysis**
PSScriptAnalyzer integration via temp-file approach. Get actionable suggestions, not just warnings.
6. **π¨ Beautiful Themes**
ISE-inspired themes for developers who love the classic look. Dark and light variants included.
7. **π Zero Configuration**
Works out of the box. Auto-detects PowerShell 7 or falls back to Windows PowerShell 5.1.
---
## β¨ Features
### MCP Tools for AI Agents
| Tool | Description | Key Params |
|------|-------------|-----------|
| `execute_powershell` | Run PS code. ANSI stripped, output capped. | `maxOutput`, `timeout` |
| `analyze_script` | Lint with PSScriptAnalyzer. | `minSeverity` |
| `get_completions` | TabExpansion2 completions. TTL-cached 5 s. | `maxResults` |
| `get_help` | Get-Help for any cmdlet/topic. | `examples`, `detailed` |
| `invoke_cmdlet` | Safe cmdlet execution. depth=2, smart fields. | `selectProperties`, `depth`, `first` |
| `list_modules` | Browse installed modules. Path excluded by default. | `filter`, `includePath` |
### MCP Resources
| Resource | Description |
|----------|-------------|
| `powershell://environment` | PS version, OS, execution policy, current user |
| `powershell://modules` | Full list of available modules |
### Token Savings β Benchmarks
| Operation | Before v1.2.0 | After v1.2.0 | Savings |
|-----------|:-------------:|:------------:|:-------:|
| `invoke_cmdlet Get-Process` | 911 KB | ~300 bytes | **β99.9%** |
| `list_modules` (66 modules) | 19 KB | ~3 KB | **β84%** |
| ANSI codes in any output | +30% overhead | 0 | **β100%** |
| `ListTools` descriptions | ~2 KB | ~700 bytes | **β65%** |
### VS Code Integration
- πΉ **F8** β Run selection / current line in PS terminal
- π **Ctrl+F1** β Show help for symbol under cursor
- π Real-time diagnostics via PSScriptAnalyzer (on save)
- π‘ Hover docs for cmdlets (`Get-ADUser`, `Set-AzVM`, etc.)
- π¨ Syntax highlighting for `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc`
---
## π¦ Installation
```bash
# Clone the repository
git clone https://github.com/mjojo/PowerShellEX.git
cd PowerShellEX
# Install dependencies
npm install
# Build
npm run build
```
Or install the pre-built VSIX directly:
```bash
code --install-extension powershell-ex-1.2.0.vsix
```
---
## π§ Usage
### In VS Code
PowerShell EX works out-of-the-box as a standard VS Code extension:
- **Execute Code:** Select code and press `F8` to run it in the terminal.
- **Get Help:** Place cursor on a cmdlet and press `Ctrl+F1` for instant documentation.
- **Diagnostics:** PSScriptAnalyzer provides real-time feedback on file save.
- **Hover Docs:** Hover over cmdlets for syntax and synopsis.
### In Antigravity (AI Agents)
Add to your Antigravity MCP settings (`.gemini/antigravity-ide/mcp_config.json`):
```json
{
"mcpServers": {
"powershell": {
"command": "node",
"args": ["d:/Projects/PowerShellEX/dist/index.js"]
}
}
}
```
### Example β AI Agent calls
```jsonc
// Minimal β AI gets clean output, no ANSI noise
{ "tool": "execute_powershell", "code": "Get-Date" }
// Invoke cmdlet β returns only Name, Id, CPU (not 911 KB)
{ "tool": "invoke_cmdlet", "cmdlet": "Get-Process",
"parameters": { "Name": "pwsh" } }
// Completions β cached, fast, compact
{ "tool": "get_completions", "code": "Get-", "cursorPosition": 4 }
// Increase output cap for large scripts
{ "tool": "execute_powershell", "code": "...", "maxOutput": 20000 }
```
---
## π Requirements
- **Node.js** 18+ (LTS recommended)
- **PowerShell** 7+ (`pwsh`) β auto-detected; falls back to Windows PowerShell 5.1
- **PSScriptAnalyzer** module (optional, for `analyze_script` tool)
```powershell
# Install PSScriptAnalyzer
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -Force
```
---
## π οΈ Development
```bash
npm run build # Production build (TypeScript β dist/)
npm run watch # Watch mode with hot reload
npm run lint # ESLint
npm run package # Build + package β .vsix
```
---
## πΊοΈ Roadmap
- [x] MCP server with 6 AI agent tools
- [x] PSScriptAnalyzer integration (temp-file, injection-safe)
- [x] Token optimization β ANSI strip, compact JSON, output cap, TTL cache
- [x] Configurable execution timeout
- [x] Smart field selection in `invoke_cmdlet` (depth=2, selectProperties)
- [x] PowerShell 7 / Windows PowerShell auto-detection + fallback
- [x] GitHub Actions CI with automatic VSIX packaging
- [ ] PowerShell Session Manager (persistent process, stateful sessions)
- [ ] Debugging support (breakpoints, stepping via DAP)
- [ ] Remote PowerShell sessions (SSH, WinRM)
- [ ] PowerShell Notebook support (.psnb)
- [ ] Performance profiler integration
---
## π License
MIT Β© 2024-2026 [Vitaly Golik (mjojo)](mailto:vitaly.golik@gmail.com)
---
<div align="center">
**β Star this repo if you find it useful!**
[Report Bug](https://github.com/mjojo/PowerShellEX/issues) Β· [Request Feature](https://github.com/mjojo/PowerShellEX/issues)
</div>
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues