-
Notifications
You must be signed in to change notification settings - Fork 254
Back language model tools and the Command Explorer with new LSP requests #2298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andyleejordan
wants to merge
4
commits into
main
Choose a base branch
from
andyleejordan/lm-tools-command-explorer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3c45bc0
Return help text from the `powerShell/showHelp` request
andyleejordan 9cd797a
Enhance `get_command` for tools and the Command Explorer
andyleejordan ac66fc4
Add a `powerShell/getModule` handler for module metadata
andyleejordan 25305c7
Add Copilot instructions documenting build and test
andyleejordan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Copilot Instructions for PowerShell Editor Services | ||
|
|
||
| ## Build & Test | ||
|
|
||
| Requires .NET SDK 8.0+. Use `dotnet` directly for building and testing — it's faster and | ||
| requires no extra tooling. The `Invoke-Build` script requires the `InvokeBuild` and `platyPS` | ||
| PowerShell modules (platyPS is `#Requires`'d at the top, so the whole script fails without it), | ||
| and is mainly needed to assemble the full PowerShell module for release. | ||
|
|
||
| ```powershell | ||
| # Build (run both; Hosting depends on the core library) | ||
| dotnet publish src/PowerShellEditorServices/PowerShellEditorServices.csproj -f netstandard2.0 | ||
| dotnet publish src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj -f net8.0 | ||
|
|
||
| # Run all unit tests | ||
| dotnet test test/PowerShellEditorServices.Test/ --framework net8.0 | ||
|
|
||
| # Run a single test by name | ||
| dotnet test test/PowerShellEditorServices.Test/ --framework net8.0 --filter "FullyQualifiedName~CompletesCommandInFile" | ||
|
|
||
| # Run tests by trait category | ||
| dotnet test test/PowerShellEditorServices.Test/ --framework net8.0 --filter "Category=Completions" | ||
|
|
||
| # Run E2E tests | ||
| dotnet test test/PowerShellEditorServices.Test.E2E/ --framework net8.0 | ||
| ``` | ||
|
|
||
| For assembling the full module or running the complete CI suite (including Windows PowerShell | ||
| 5.1 targets), use `Invoke-Build` with the `InvokeBuild` and `platyPS` modules installed: | ||
|
|
||
| ```powershell | ||
| Invoke-Build Build # full build + module assembly + help generation | ||
| Invoke-Build TestPS74 # unit tests via build script | ||
| Invoke-Build TestE2EPwsh # E2E tests via build script | ||
| Invoke-Build Build -Configuration Release # required before PRs (enforces XML doc comments) | ||
| ``` | ||
|
|
||
| `src/PowerShellEditorServices.Hosting/BuildInfo.cs` is auto-generated by the build script and | ||
| git-ignored for changes. Do not edit it manually. | ||
|
|
||
| ## Architecture | ||
|
|
||
| PowerShell Editor Services (PSES) is a **Language Server Protocol (LSP)** and **Debug Adapter | ||
| Protocol (DAP)** server for PowerShell, consumed by VS Code and other editors. | ||
|
|
||
| ### Projects | ||
|
|
||
| - **`src/PowerShellEditorServices`** (`netstandard2.0`) — Core library containing all LSP/DAP | ||
| handlers, services, and the PowerShell execution engine. Namespace: | ||
| `Microsoft.PowerShell.EditorServices`. | ||
| - **`src/PowerShellEditorServices.Hosting`** (`net8.0`, `net462`) — Entry point layer that loads | ||
| PSES into a PowerShell process via `StartEditorServicesCommand`. Uses a custom | ||
| `AssemblyLoadContext` (`PsesLoadContext`) on .NET Core to isolate dependencies. | ||
| - **`module/PowerShellEditorServices/`** — The shipped PowerShell module. The build assembles | ||
| compiled binaries into `bin/Core/` (net8.0) and `bin/Desktop/` (net462). The module manifest | ||
| loads the appropriate DLL based on PowerShell edition. | ||
|
|
||
| ### Key Services (registered in `PsesServiceCollectionExtensions`) | ||
|
|
||
| - **`PsesInternalHost`** — The central PowerShell execution host. Also implements | ||
| `IRunspaceContext` and `IInternalPowerShellExecutionService`. | ||
| - **`WorkspaceService`** — Manages open documents and workspace files. | ||
| - **`SymbolsService`** — Provides symbol navigation (go-to-definition, find references). | ||
| - **`AnalysisService`** — Integrates PSScriptAnalyzer for real-time diagnostics. | ||
| - **`ConfigurationService`** — Manages editor/client settings. | ||
| - **`ExtensionService`** — Supports the `$psEditor` API for editor extensions. | ||
|
|
||
| ### LSP/DAP Handler Pattern | ||
|
|
||
| Handlers live under `Services/<Feature>/Handlers/` and follow a consistent pattern: | ||
|
|
||
| - Class name: `Pses<Feature>Handler`, marked `internal` | ||
| - Inherits from an OmniSharp base class (e.g., `CompletionHandlerBase`, `HoverHandlerBase`) | ||
| - Dependencies injected via constructor (`ILoggerFactory`, services) | ||
| - Overrides `CreateRegistrationOptions()` and `Handle()` | ||
| - Uses `LspUtils.PowerShellDocumentSelector` for document registration | ||
|
|
||
| ### Server Setup | ||
|
|
||
| - `PsesLanguageServer` — Configures and runs the LSP server using OmniSharp | ||
| - `PsesDebugServer` — Configures and runs the DAP server | ||
| - Both use `Microsoft.Extensions.DependencyInjection` for service registration | ||
|
|
||
| ## Conventions | ||
|
|
||
| ### C# Style | ||
|
|
||
| - All files require the copyright header: `// Copyright (c) Microsoft Corporation.` / | ||
| `// Licensed under the MIT License.` | ||
| - `.editorconfig` enforces many rules as **errors**, including unused variables, async/threading | ||
| rules (`VSTHRD*`), and modern C# idioms (pattern matching, null checks, expression bodies). | ||
| - Roslynator analyzers are enabled for formatting and code quality. | ||
| - Use `Microsoft.Extensions.Logging` (`ILogger<T>` via `ILoggerFactory`) for all logging. | ||
|
|
||
| ### Testing | ||
|
|
||
| - **Framework:** xUnit with `Xunit.SkippableFact` for conditionally skipped tests. | ||
| - **Host setup:** Use `PsesHostFactory.Create(loggerFactory)` to get an isolated | ||
| `PsesInternalHost` for testing. Tests implement `IAsyncLifetime` for async setup/teardown. | ||
| - **Traits:** Tests use `[Trait("Category", "...")]` for filtering (e.g., `"Completions"`, | ||
| `"Symbols"`). | ||
| - **Fixtures:** Test PowerShell scripts live in `test/PowerShellEditorServices.Test/Fixtures/`. | ||
| - **E2E tests** are in a separate project (`PowerShellEditorServices.Test.E2E`) and test the | ||
| full LSP client-server interaction. | ||
|
|
||
| ### Multi-targeting | ||
|
|
||
| The core library targets `netstandard2.0` for compatibility with both .NET Core and .NET | ||
| Framework. The hosting project and tests dual-target `net8.0` and `net462` (Windows PowerShell | ||
| 5.1). Non-Windows platforms skip `net462` targets. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.