Add positron.ai.getAllowedCommands() API for LLM extensions#14913
Draft
samclark2015 wants to merge 3 commits into
Draft
Add positron.ai.getAllowedCommands() API for LLM extensions#14913samclark2015 wants to merge 3 commits into
samclark2015 wants to merge 3 commits into
Conversation
Adds a new method to the positron.ai namespace that returns all registered Positron commands with their IDs, descriptions, parameter metadata, keybindings, and source (builtin vs. extension). Descriptions are resolved from four sources in priority order: CommandsRegistry metadata, MenuRegistry.getCommands() titles, CommandPalette menu item titles (covers undo/redo and similar MultiCommand registrations), and EditorExtensionsRegistry labels. Also adds a "Positron Assistant: Show Allowed Commands" command palette entry in the positron-assistant extension that dumps the result as formatted JSON in a new editor tab, for manual testing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moves the "Show Allowed AI Commands" command from the positron-assistant extension into positronAssistant.contribution.ts in core, where it reads the command registries directly without going through the extension host. Also removes keybindings from the positron.ai.getAllowedCommands() return type and implementation, simplifying the IPC payload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. |
…agent-allowed-commands
| */ | ||
| export interface AllowedCommandSource { | ||
| /** `'builtin'` for core Positron/VS Code commands; `'extension'` for extension-contributed commands. */ | ||
| type: 'builtin' | 'extension'; |
Contributor
There was a problem hiding this comment.
🎉 ooh, it would be great if we could filter on extension vs builtin commands in the future (I don't think we'll need it for the curated Assistant experience).
| * Return all registered commands with their IDs, descriptions, and parameter metadata. | ||
| * Internal commands (IDs starting with '_') are excluded. | ||
| */ | ||
| async $getAllowedCommands(): Promise<ISerializedAllowedCommand[]> { |
Contributor
There was a problem hiding this comment.
For this, I was thinking we may want to limit the commands we expose from this endpoint to be ones that we also show in the command palette (f1: true). This would ensure that the user can also lookup/validate the commands the Assistant is running from this endpoint. We're more likely to have some documentation of those commands as well.
Or we allow filtering on f1 at the very least!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a new
positron.ai.getAllowedCommands()extension API that returns all registered Positron commands with their IDs, descriptions, argument metadata, and source (builtin vs. extension). This gives LLM extensions a structured way to discover what commands are available to invoke on behalf of users, with a future allowlist in mind.Descriptions are resolved from four sources in priority order:
CommandsRegistrymetadata,MenuRegistry.getCommands()titles,MenuId.CommandPalettemenu item titles (catchesMultiCommand/EditorCommandregistrations like undo/redo that useappendMenuIteminstead ofaddCommand), andEditorExtensionsRegistrylabels. Also adds a Developer: Show Allowed AI Commands command in core (positronAssistant.contribution.ts) that dumps the full result as formatted JSON in a new editor tab, for manual testing.Release Notes
New Features
positron.ai.getAllowedCommands()API for LLM extensions to discover available Positron commandsBug Fixes
Validation Steps
@:assistant
undoandredohave adescriptionfield (e.g."Undo","Redo") andsource.type: "builtin"source.type: "extension"withidanddisplayName_