Path: blob/main/src/vscode-dts/vscode.proposed.chatContextProvider.d.ts
5220 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/456declare module 'vscode' {78// https://github.com/microsoft/vscode/issues/271104 @alexr00910export namespace chat {1112/**13* Register a chat workspace context provider. Workspace context is automatically included in all chat requests.14*15* To ensure your extension is activated when chat context is requested, make sure to include the following activations events:16* - If your extension implements `provideWorkspaceChatContext` or `provideChatContextForResource`, find an activation event which is a good signal to activate.17* Ex: `onLanguage:<languageId>`, `onWebviewPanel:<viewType>`, etc.`18* - If your extension implements `provideChatContextExplicit`, your extension will be automatically activated when the user requests explicit context.19*20* @param id Unique identifier for the provider.21* @param provider The chat workspace context provider.22*/23export function registerChatWorkspaceContextProvider(id: string, provider: ChatWorkspaceContextProvider): Disposable;2425/**26* Register a chat explicit context provider. Explicit context items are shown as options when the user explicitly attaches context.27*28* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.29*30* @param id Unique identifier for the provider.31* @param provider The chat explicit context provider.32*/33export function registerChatExplicitContextProvider(id: string, provider: ChatExplicitContextProvider): Disposable;3435/**36* Register a chat resource context provider. Resource context is provided for a specific resource.37* Make sure to pass a selector that matches the resource you want to provide context for.38*39* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.40*41* @param selector Document selector to filter which resources the provider is called for.42* @param id Unique identifier for the provider.43* @param provider The chat resource context provider.44*/45export function registerChatResourceContextProvider(selector: DocumentSelector, id: string, provider: ChatResourceContextProvider): Disposable;4647/**48* Register a chat context provider.49*50* @deprecated Use {@link registerChatWorkspaceContextProvider}, {@link registerChatExplicitContextProvider}, or {@link registerChatResourceContextProvider} instead.51*52* @param selector Optional document selector to filter which resources the provider is called for. If omitted, the provider will only be called for explicit context requests.53* @param id Unique identifier for the provider.54* @param provider The chat context provider.55*/56export function registerChatContextProvider(selector: DocumentSelector | undefined, id: string, provider: ChatContextProvider): Disposable;5758}5960export interface ChatContextItem {61/**62* Icon for the context item.63* - If `icon` is not defined, no icon is shown.64* - If `icon` is defined and is a file or folder icon, the icon is derived from {@link resourceUri} if `resourceUri` is defined.65* - Otherwise, `icon` is used.66*/67icon?: ThemeIcon;68/**69* Human readable label for the context item.70* If not set, the label is derived from {@link resourceUri}.71*/72label?: string;73/**74* A resource URI for the context item.75* Used to derive the {@link label} and {@link icon} if they are not set.76*/77resourceUri?: Uri;78/**79* An optional description of the context item, e.g. to describe the item to the language model.80*/81modelDescription?: string;82/**83* An optional tooltip to show when hovering over the context item in the UI.84*/85tooltip?: MarkdownString;86/**87* The value of the context item. Can be omitted when returned from one of the `provide` methods if the provider supports `resolveChatContext`.88*/89value?: string;90/**91* An optional command that is executed when the context item is clicked.92* The original context item will be passed as the first argument to the command.93*/94command?: Command;95}9697export interface ChatWorkspaceContextProvider<T extends ChatContextItem = ChatContextItem> {9899/**100* An optional event that should be fired when the workspace chat context has changed.101*/102onDidChangeWorkspaceChatContext?: Event<void>;103104/**105* Provide a list of chat context items to be included as workspace context for all chat requests.106* This should be used very sparingly to avoid providing useless context and to avoid using up the context window.107* A good example use case is to provide information about which branch the user is working on in a source control context.108*109* @param token A cancellation token.110*/111provideChatContext(token: CancellationToken): ProviderResult<T[]>;112}113114export interface ChatExplicitContextProvider<T extends ChatContextItem = ChatContextItem> {115116/**117* Provide a list of chat context items that a user can choose from. These context items are shown as options when the user explicitly attaches context.118* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.119* `resolveChatContext` is only called for items that do not have a `value`.120*121* @param token A cancellation token.122*/123provideChatContext(token: CancellationToken): ProviderResult<T[]>;124125/**126* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.127*128* @param context The context item to resolve.129* @param token A cancellation token.130*/131resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;132}133134export interface ChatResourceContextProvider<T extends ChatContextItem = ChatContextItem> {135136/**137* Given a particular resource, provide a chat context item for it. This is used for implicit context (see the settings `chat.implicitContext.enabled` and `chat.implicitContext.suggestedContext`).138* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.139* `resolveChatContext` is only called for items that do not have a `value`.140*141* Called when the resource is a webview or a text editor.142*143* @param options Options include the resource for which to provide context.144* @param token A cancellation token.145*/146provideChatContext(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;147148/**149* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.150*151* @param context The context item to resolve.152* @param token A cancellation token.153*/154resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;155}156157/**158* @deprecated Use {@link ChatWorkspaceContextProvider}, {@link ChatExplicitContextProvider}, or {@link ChatResourceContextProvider} instead.159*/160export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {161162/**163* An optional event that should be fired when the workspace chat context has changed.164* @deprecated Use {@link ChatWorkspaceContextProvider.onDidChangeWorkspaceChatContext} instead.165*/166onDidChangeWorkspaceChatContext?: Event<void>;167168/**169* Provide a list of chat context items to be included as workspace context for all chat requests.170* @deprecated Use {@link ChatWorkspaceContextProvider.provideChatContext} instead.171*/172provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;173174/**175* Provide a list of chat context items that a user can choose from.176* @deprecated Use {@link ChatExplicitContextProvider.provideChatContext} instead.177*/178provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;179180/**181* Given a particular resource, provide a chat context item for it.182* @deprecated Use {@link ChatResourceContextProvider.provideChatContext} instead.183*/184provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;185186/**187* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.188* @deprecated Use the `resolveChatContext` method on the specific provider type instead.189*/190resolveChatContext?(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;191}192193}194195196