-
Notifications
You must be signed in to change notification settings - Fork 731
Expand file tree
/
Copy pathvscode.proposed.chatContextProvider.d.ts
More file actions
221 lines (190 loc) · 9.53 KB
/
vscode.proposed.chatContextProvider.d.ts
File metadata and controls
221 lines (190 loc) · 9.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/271104 @alexr00
export namespace chat {
/**
* Register a chat workspace context provider. Workspace context is automatically included in all chat requests.
*
* To ensure your extension is activated when chat context is requested, make sure to include the following activations events:
* - If your extension implements `provideWorkspaceChatContext` or `provideChatContextForResource`, find an activation event which is a good signal to activate.
* Ex: `onLanguage:<languageId>`, `onWebviewPanel:<viewType>`, etc.`
* - If your extension implements `provideChatContextExplicit`, your extension will be automatically activated when the user requests explicit context.
*
* @param id Unique identifier for the provider.
* @param provider The chat workspace context provider.
*/
export function registerChatWorkspaceContextProvider(id: string, provider: ChatWorkspaceContextProvider): Disposable;
/**
* Register a chat explicit context provider. Explicit context items are shown as options when the user explicitly attaches context use the "Attache Context" action in the chat input box.
*
* Explicit context providers should also be statically contributed in package.json using the `chatContext` contribution point.
*
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
*
* @param id Unique identifier for the provider.
* @param provider The chat explicit context provider.
*/
export function registerChatExplicitContextProvider(id: string, provider: ChatExplicitContextProvider): Disposable;
/**
* Register a chat resource context provider. Resource context is provided for a specific resource.
* Make sure to pass a selector that matches the resource you want to provide context for.
*
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
*
* @param selector Document selector to filter which resources the provider is called for.
* @param id Unique identifier for the provider.
* @param provider The chat resource context provider.
*/
export function registerChatResourceContextProvider(selector: DocumentSelector, id: string, provider: ChatResourceContextProvider): Disposable;
/**
* Register a chat context provider.
*
* @deprecated Use {@link registerChatWorkspaceContextProvider}, {@link registerChatExplicitContextProvider}, or {@link registerChatResourceContextProvider} instead.
*
* @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.
* @param id Unique identifier for the provider.
* @param provider The chat context provider.
*/
export function registerChatContextProvider(selector: DocumentSelector | undefined, id: string, provider: ChatContextProvider): Disposable;
}
export interface ChatContextItem {
/**
* Icon for the context item.
* - If `icon` is not defined, no icon is shown.
* - If `icon` is defined and is a file or folder icon, the icon is derived from {@link resourceUri} if `resourceUri` is defined.
* - Otherwise, `icon` is used.
*/
icon?: ThemeIcon;
/**
* Human readable label for the context item.
* If not set, the label is derived from {@link resourceUri}.
*/
label?: string;
/**
* A resource URI for the context item.
* Used to derive the {@link label} and {@link icon} if they are not set.
*/
resourceUri?: Uri;
/**
* An optional description of the context item, e.g. to describe the item to the language model.
*/
modelDescription?: string;
/**
* An optional tooltip to show when hovering over the context item in the UI.
*/
tooltip?: MarkdownString;
/**
* The value of the context item. Can be omitted when returned from one of the `provide` methods if the provider supports `resolveChatContext`.
*/
value?: string;
/**
* An optional command that is executed when the context item is clicked.
* The original context item will be passed as the first argument to the command.
*/
command?: Command;
}
export interface ChatWorkspaceContextProvider<T extends ChatContextItem = ChatContextItem> {
/**
* An optional event that should be fired when the workspace chat context has changed.
*/
onDidChangeWorkspaceChatContext?: Event<void>;
/**
* Provide a list of chat context items to be included as workspace context for all chat requests.
* This should be used very sparingly to avoid providing useless context and to avoid using up the context window.
* A good example use case is to provide information about which branch the user is working on in a source control context.
*
* @param token A cancellation token.
*/
provideWorkspaceChatContext(token: CancellationToken): ProviderResult<T[]>;
/**
* @deprecated
*/
provideChatContext?(token: CancellationToken): ProviderResult<T[]>;
}
export interface ChatExplicitContextProvider<T extends ChatContextItem = ChatContextItem> {
/**
* 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.
* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.
* `resolveChatContext` is only called for items that do not have a `value`.
*
* @param token A cancellation token.
*/
provideExplicitChatContext(token: CancellationToken): ProviderResult<T[]>;
/**
* @deprecated
*/
provideChatContext?(token: CancellationToken): ProviderResult<T[]>;
/**
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
*
* @param context The context item to resolve.
* @param token A cancellation token.
*/
resolveExplicitChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
/**
* @deprecated
*/
resolveChatContext?(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
}
export interface ChatResourceContextProvider<T extends ChatContextItem = ChatContextItem> {
/**
* 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`).
* Chat context items can be provided without a `value`, as the `value` can be resolved later using `resolveChatContext`.
* `resolveChatContext` is only called for items that do not have a `value`.
*
* Called when the resource is a webview or a text editor.
*
* @param options Options include the resource for which to provide context.
* @param token A cancellation token.
*/
provideResourceChatContext(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
/**
* @deprecated
*/
provideChatContext?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
/**
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
*
* @param context The context item to resolve.
* @param token A cancellation token.
*/
resolveResourceChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
/**
* @deprecated
*/
resolveChatContext?(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
}
/**
* @deprecated Use {@link ChatWorkspaceContextProvider}, {@link ChatExplicitContextProvider}, or {@link ChatResourceContextProvider} instead.
*/
export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {
/**
* An optional event that should be fired when the workspace chat context has changed.
* @deprecated Use {@link ChatWorkspaceContextProvider.onDidChangeWorkspaceChatContext} instead.
*/
onDidChangeWorkspaceChatContext?: Event<void>;
/**
* Provide a list of chat context items to be included as workspace context for all chat requests.
* @deprecated Use {@link ChatWorkspaceContextProvider.provideWorkspaceChatContext} instead.
*/
provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;
/**
* Provide a list of chat context items that a user can choose from.
* @deprecated Use {@link ChatExplicitContextProvider.provideExplicitChatContext} instead.
*/
provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;
/**
* Given a particular resource, provide a chat context item for it.
* @deprecated Use {@link ChatResourceContextProvider.provideResourceChatContext} instead.
*/
provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
/**
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
* @deprecated Use the `resolveChatContext` method on the specific provider type instead.
*/
resolveChatContext?(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
}
}