$ show PowerShell/vscode-powershell
This repository is the official Visual Studio Code extension for PowerShell (published as ms-vscode.PowerShell). It provides rich language support including IntelliSense, code navigation, formatting, PSScriptAnalyzer linting, debugging with a custom debug adapter, integrated PowerShell console, Pester test runner, ISE compatibility mode, command explorer, help view, alias expansion, remote file editing, and language model tools for AI copilot integration. The extension acts as a Language Server Protocol (LSP) client that communicates with the external PowerShellEditorServices server, and uses the Debug Adapter Protocol for debugging. It supports all major platforms (Windows, macOS, Linux) and multiple PowerShell editions (stable, preview, daily, etc.). The architecture follows a modular feature-class pattern under `src/features/`, with a central `SessionManager` handling the PowerShell process lifecycle and language client connection. The extension is well-tested with unit and integration tests across CI, and its code demonstrates solid TypeScript patterns, clean separation of concerns, and reusable abstractions such as `LanguageClientConsumer` for async LSP client access and `PowerShellExeFinder` for cross-platform PowerShell discovery. While the codebase is actively maintained and keeps pace with VS Code API changes, it contains some deprecated settings and minor complexity in session management. Overall, it is a professional-grade VS Code extension with a few genuinely reusable components that could benefit other extensions or tools dealing with PowerShell or LSP clients.
The LLM identified 3 files worth highlighting for reuse:
Implements `PowerShellExeFinder`, a standalone algorithm for discovering PowerShell installations across Windows, macOS, and Linux. Uses async generators to yield `PossiblePowerShellExe` objects, checking existence via filesystem and platform-specific methods (registry, environment variables, snap, homebrew, dotnet tool). This component is self-contained (imports only node built-ins and a simple `PossiblePowerShellExe` type) and could be extracted for any project needing to locate PowerShell on a system. The systematic enumeration with fallbacks and platform-adaptive logic demonstrates non-obvious craftsmanship.
A generic multi-select QuickPick control with checkboxes and a confirm button. It uses VS Code's `QuickPick` API with custom `QuickPickItem` decorations to show check state and allows selecting/deselecting items, with a summary label of how many are selected. The component is fully isolated (only imports `vscode`), handles cancellation gracefully, and returns a promise of user choice. This is a reusable UI pattern for any VS Code extension that needs a list with multiple selection and confirmation (e.g., choosing rules to enable). The implementation is clean and avoids common pitfalls like mutating external state.
An abstract base class (`LanguageClientConsumer`) that provides a clear pattern for features needing an asynchronously-acquired language client. It exposes a `getLanguageClient()` method that returns a promise, resolves once the client is set, and shows a cancellable progress notification in the VS Code status bar. Classes extend it and implement `setLanguageClient()` for initialization. This decouples feature classes from the session startup logic and can be reused in any VS Code extension that uses `vscode-languageclient` and wants to gate feature availability on client readiness. The design is clean, lightweight, and avoids tight coupling to the session manager.