Skip to content

Add PowerShell language model tools and redesign the Command Explorer#5508

Draft
andyleejordan wants to merge 5 commits into
mainfrom
andyleejordan/lm-tools-command-explorer
Draft

Add PowerShell language model tools and redesign the Command Explorer#5508
andyleejordan wants to merge 5 commits into
mainfrom
andyleejordan/lm-tools-command-explorer

Conversation

@andyleejordan

@andyleejordan andyleejordan commented Jun 9, 2026

Copy link
Copy Markdown
Member

Adds PowerShell language model tools, redesigns the Command Explorer, and renders Show Help in a read-only editor pane. Backed by new LSP requests in PowerShell/PowerShellEditorServices#2298 — that PR must land with this one.

  1. Render Show Help in a read-only editor pane — request help text via powerShell/showHelp and show it in a virtual document; fix the off-word getWordRangeAtPosition bug where an empty selection sent the whole document.
  2. Redesign the Command Explorer around modules and lazy loading — lazy module→command tree, versioned module nodes, getModule hover tooltips (cached), a neutral "Functions & Scripts" bucket with a folder icon, excludeParameters/excludeDefaultFunctions request flags, inline-action gating to viewItem == command, and defaulting the view to visible (with a revertIsObservable guard so the ISE compatibility tests still pass).
  3. Add PowerShell language model tools — four read-only tools (powershell_get_command, powershell_get_help, powershell_get_environment, powershell_expand_alias), each backed by an existing PSES request, contributed in package.json and wired up in extension.ts.
  4. Document the cross-repo dev and test cycle for Copilot.

Drafted by Copilot (Claude Opus 4.8)

andyleejordan and others added 4 commits June 9, 2026 15:22
Show Help previously printed `Get-Help` output into the integrated console and,
when nothing was selected, sent the entire document as the help target. The
latter was a `getWordRangeAtPosition` bug: off a word it returns `undefined`,
and `doc.getText(undefined)` returns the whole document.

Resolve the word at the cursor explicitly (falling back to the selection), send
it to the new `powerShell/showHelp` request, and render the returned text in a
read-only virtual document so help opens in a proper editor pane instead of an
editable untitled buffer.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Command Explorer fetched the full command table up front (names, modules,
and parameter metadata for everything), which took minutes to populate and
showed a flat, hard-to-scan list. Rework it into a lazy, module-grouped tree:

- Top-level nodes are modules (with version), expanded on demand; their
  commands are fetched per module with `excludeParameters` so only names and
  modules cross the wire.
- Module-less commands are collected under a neutral "Functions & Scripts"
  node with a folder icon, and the request sets `excludeDefaultFunctions` so
  PowerShell's default-session plumbing doesn't clutter it.
- Hovering a module shows its metadata via the new `powerShell/getModule`
  request, cached so repeated hovers don't re-fetch.
- The inline Show Help / Insert command actions are gated to `viewItem ==
  command` so they no longer appear on module nodes.

Default the Command Explorer to visible. Because its default now equals the
value the ISE profile sets, the ISE compatibility tests could no longer
observe a revert by inequality; guard those assertions with
`revertIsObservable`, which skips settings whose default already matches the
ISE value.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Register four read-only language model tools that Copilot can call when
working with PowerShell, each backed by an existing PSES request so they
report exactly what the user's session would:

- `powershell_get_command` lists commands, optionally scoped by name and/or
  module, using the now-parameterized `powerShell/getCommand` request with
  `excludeParameters` so large listings stay cheap.
- `powershell_get_help` returns `Get-Help` output via `powerShell/showHelp`.
- `powershell_get_environment` reports the PowerShell version table.
- `powershell_expand_alias` resolves aliases to their underlying commands.

All four are read-only and declare no confirmation requirement. Contribute
them in `package.json` and wire up `LanguageModelToolsFeature` in
`extension.ts`.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record that `modules/` is a symlink to the sibling PowerShellEditorServices
`module` directory, so building PSES deploys its DLLs straight into the path
the extension and its tests load from — meaning C# changes require rebuilding
PSES by hand, and `npm test` exercises the real Extension Host against the
locally built server. This trips up anyone (including Copilot) who edits PSES
and wonders why the extension didn't pick it up.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Point the `PowerShellEditorServices` checkout at the coupled PR branch
`andyleejordan/lm-tools-command-explorer` so #5508's new language model
tool tests run against the server contract they depend on (name/module
filtering on `getCommand`, `showHelp` returning `helpText`).

Must be reverted before merge — once PSES #2298 lands on `main`, the
default checkout passes.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant