Skip to content

Commit 6622223

Browse files
Copilotalexr00
andcommitted
Initial progress report: Plan to add Apply Suggestion with Copilot to Comments view
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent f6d2c7a commit 6622223

File tree

4 files changed

+256
-89
lines changed

4 files changed

+256
-89
lines changed

src/@types/vscode.proposed.chatContextProvider.d.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ declare module 'vscode' {
1616
* Providers registered without a selector will not be called for resource-based context.
1717
* - Explicitly. These context items are shown as options when the user explicitly attaches context.
1818
*
19-
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
19+
* To ensure your extension is activated when chat context is requested, make sure to include the following activations events:
20+
* - If your extension implements `provideWorkspaceChatContext` or `provideChatContextForResource`, find an activation event which is a good signal to activate.
21+
* Ex: `onLanguage:<languageId>`, `onWebviewPanel:<viewType>`, etc.`
22+
* - If your extension implements `provideChatContextExplicit`, your extension will be automatically activated when the user requests explicit context.
2023
*
2124
* @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.
2225
* @param id Unique identifier for the provider.
@@ -49,7 +52,7 @@ declare module 'vscode' {
4952
value?: string;
5053
/**
5154
* An optional command that is executed when the context item is clicked.
52-
* The original context item will be passed as an argument to the command.
55+
* The original context item will be passed as the first argument to the command.
5356
*/
5457
command?: Command;
5558
}
@@ -62,7 +65,11 @@ declare module 'vscode' {
6265
onDidChangeWorkspaceChatContext?: Event<void>;
6366

6467
/**
65-
* Provide a list of chat context items to be included as workspace context for all chat sessions.
68+
* TODO @API: should this be a separate provider interface?
69+
*
70+
* Provide a list of chat context items to be included as workspace context for all chat requests.
71+
* This should be used very sparingly to avoid providing useless context and to avoid using up the context window.
72+
* A good example use case is to provide information about which branch the user is working on in a source control context.
6673
*
6774
* @param token A cancellation token.
6875
*/

src/@types/vscode.proposed.chatParticipantAdditions.d.ts

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ declare module 'vscode' {
8080
constructor(value: Uri, license: string, snippet: string);
8181
}
8282

83-
export class ChatPrepareToolInvocationPart {
84-
toolName: string;
85-
constructor(toolName: string);
83+
export interface ChatToolInvocationStreamData {
84+
/**
85+
* Partial or not-yet-validated arguments that have streamed from the language model.
86+
* Tools may use this to render interim UI while the full invocation input is collected.
87+
*/
88+
readonly partialInput?: unknown;
8689
}
8790

8891
export interface ChatTerminalToolInvocationData {
@@ -104,7 +107,7 @@ declare module 'vscode' {
104107
isConfirmed?: boolean;
105108
isComplete?: boolean;
106109
toolSpecificData?: ChatTerminalToolInvocationData;
107-
fromSubAgent?: boolean;
110+
subAgentInvocationId?: string;
108111
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
109112

110113
constructor(toolName: string, toolCallId: string, isError?: boolean);
@@ -176,7 +179,7 @@ declare module 'vscode' {
176179
constructor(uris: Uri[], callback: () => Thenable<unknown>);
177180
}
178181

179-
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
182+
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
180183
export class ChatResponseWarningPart {
181184
value: MarkdownString;
182185
constructor(value: string | MarkdownString);
@@ -349,7 +352,21 @@ declare module 'vscode' {
349352

350353
codeCitation(value: Uri, license: string, snippet: string): void;
351354

352-
prepareToolInvocation(toolName: string): void;
355+
/**
356+
* Begin a tool invocation in streaming mode. This creates a tool invocation that will
357+
* display streaming progress UI until the tool is actually invoked.
358+
* @param toolCallId Unique identifier for this tool call, used to correlate streaming updates and final invocation.
359+
* @param toolName The name of the tool being invoked.
360+
* @param streamData Optional initial streaming data with partial arguments.
361+
*/
362+
beginToolInvocation(toolCallId: string, toolName: string, streamData?: ChatToolInvocationStreamData & { subagentInvocationId?: string }): void;
363+
364+
/**
365+
* Update the streaming data for a tool invocation that was started with `beginToolInvocation`.
366+
* @param toolCallId The tool call ID that was passed to `beginToolInvocation`.
367+
* @param streamData New streaming data with updated partial arguments.
368+
*/
369+
updateToolInvocation(toolCallId: string, streamData: ChatToolInvocationStreamData): void;
353370

354371
push(part: ExtendedChatResponsePart): void;
355372

@@ -668,6 +685,39 @@ declare module 'vscode' {
668685

669686
export interface LanguageModelToolInvocationOptions<T> {
670687
model?: LanguageModelChat;
688+
chatStreamToolCallId?: string;
689+
}
690+
691+
export interface LanguageModelToolInvocationStreamOptions<T> {
692+
/**
693+
* Raw argument payload, such as the streamed JSON fragment from the language model.
694+
*/
695+
readonly rawInput?: unknown;
696+
697+
readonly chatRequestId?: string;
698+
/** @deprecated Use {@link chatSessionResource} instead */
699+
readonly chatSessionId?: string;
700+
readonly chatSessionResource?: Uri;
701+
readonly chatInteractionId?: string;
702+
}
703+
704+
export interface LanguageModelToolStreamResult {
705+
/**
706+
* A customized progress message to show while the tool runs.
707+
*/
708+
invocationMessage?: string | MarkdownString;
709+
}
710+
711+
export interface LanguageModelTool<T> {
712+
/**
713+
* Called zero or more times before {@link LanguageModelTool.prepareInvocation} while the
714+
* language model streams argument data for the invocation. Use this to update progress
715+
* or UI with the partial arguments that have been generated so far.
716+
*
717+
* Implementations must be free of side-effects and should be resilient to receiving
718+
* malformed or incomplete input.
719+
*/
720+
handleToolStream?(options: LanguageModelToolInvocationStreamOptions<T>, token: CancellationToken): ProviderResult<LanguageModelToolStreamResult>;
671721
}
672722

673723
export interface ChatRequest {

src/@types/vscode.proposed.chatParticipantPrivate.d.ts

Lines changed: 24 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ declare module 'vscode' {
6161
readonly attempt: number;
6262

6363
/**
64-
* The session identifier for this chat request
64+
* The session identifier for this chat request.
65+
*
66+
* @deprecated Use {@link chatSessionResource} instead.
6567
*/
6668
readonly sessionId: string;
6769

70+
/**
71+
* The resource URI for the chat session this request belongs to.
72+
*/
73+
readonly sessionResource: Uri;
74+
6875
/**
6976
* If automatic command detection is enabled.
7077
*/
@@ -93,7 +100,16 @@ declare module 'vscode' {
93100
*/
94101
readonly editedFileEvents?: ChatRequestEditedFileEvent[];
95102

96-
readonly isSubagent?: boolean;
103+
/**
104+
* Unique ID for the subagent invocation, used to group tool calls from the same subagent run together.
105+
* Pass this to tool invocations when calling tools from within a subagent context.
106+
*/
107+
readonly subAgentInvocationId?: string;
108+
109+
/**
110+
* Display name of the subagent that is invoking this request.
111+
*/
112+
readonly subAgentName?: string;
97113
}
98114

99115
export enum ChatRequestEditedFileEventKind {
@@ -230,13 +246,15 @@ declare module 'vscode' {
230246

231247
export interface LanguageModelToolInvocationOptions<T> {
232248
chatRequestId?: string;
249+
/** @deprecated Use {@link chatSessionResource} instead */
233250
chatSessionId?: string;
251+
chatSessionResource?: Uri;
234252
chatInteractionId?: string;
235253
terminalCommand?: string;
236254
/**
237-
* Lets us add some nicer UI to toolcalls that came from a sub-agent, but in the long run, this should probably just be rendered in a similar way to thinking text + tool call groups
255+
* Unique ID for the subagent invocation, used to group tool calls from the same subagent run together.
238256
*/
239-
fromSubAgent?: boolean;
257+
subAgentInvocationId?: string;
240258
}
241259

242260
export interface LanguageModelToolInvocationPrepareOptions<T> {
@@ -245,7 +263,9 @@ declare module 'vscode' {
245263
*/
246264
input: T;
247265
chatRequestId?: string;
266+
/** @deprecated Use {@link chatSessionResource} instead */
248267
chatSessionId?: string;
268+
chatSessionResource?: Uri;
249269
chatInteractionId?: string;
250270
}
251271

@@ -319,65 +339,4 @@ declare module 'vscode' {
319339
}
320340

321341
// #endregion
322-
323-
// #region CustomAgentsProvider
324-
325-
/**
326-
* Represents a custom agent resource file (e.g., .agent.md or .prompt.md) available for a repository.
327-
*/
328-
export interface CustomAgentResource {
329-
/**
330-
* The unique identifier/name of the custom agent resource.
331-
*/
332-
readonly name: string;
333-
334-
/**
335-
* A description of what the custom agent resource does.
336-
*/
337-
readonly description: string;
338-
339-
/**
340-
* The URI to the agent or prompt resource file.
341-
*/
342-
readonly uri: Uri;
343-
344-
/**
345-
* Indicates whether the custom agent resource is editable. Defaults to false.
346-
*/
347-
readonly isEditable?: boolean;
348-
}
349-
350-
/**
351-
* Options for querying custom agents.
352-
*/
353-
export interface CustomAgentQueryOptions { }
354-
355-
/**
356-
* A provider that supplies custom agent resources (from .agent.md and .prompt.md files) for repositories.
357-
*/
358-
export interface CustomAgentsProvider {
359-
/**
360-
* An optional event to signal that custom agents have changed.
361-
*/
362-
readonly onDidChangeCustomAgents?: Event<void>;
363-
364-
/**
365-
* Provide the list of custom agent resources available for a given repository.
366-
* @param options Optional query parameters.
367-
* @param token A cancellation token.
368-
* @returns An array of custom agent resources or a promise that resolves to such.
369-
*/
370-
provideCustomAgents(options: CustomAgentQueryOptions, token: CancellationToken): ProviderResult<CustomAgentResource[]>;
371-
}
372-
373-
export namespace chat {
374-
/**
375-
* Register a provider for custom agents.
376-
* @param provider The custom agents provider.
377-
* @returns A disposable that unregisters the provider when disposed.
378-
*/
379-
export function registerCustomAgentsProvider(provider: CustomAgentsProvider): Disposable;
380-
}
381-
382-
// #endregion
383342
}

0 commit comments

Comments
 (0)