Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid "slash command" name in agent API #202729

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ suite('chat', () => {
deferred.complete(request);
return null;
});
agent.slashCommandProvider = {
provideSlashCommands: (_token) => {
agent.subCommandProvider = {
provideSubCommands: (_token) => {
return [{ name: 'hello', description: 'Hello' }];
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/api/common/extHostChatAgents2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ export class ExtHostChatAgents2 implements ExtHostChatAgentsShape2 {

class ExtHostChatAgent<TResult extends vscode.ChatAgentResult2> {

private _slashCommandProvider: vscode.ChatAgentSlashCommandProvider | undefined;
private _lastSlashCommands: vscode.ChatAgentSlashCommand[] | undefined;
private _slashCommandProvider: vscode.ChatAgentSubCommandProvider | undefined;
private _lastSlashCommands: vscode.ChatAgentSubCommand[] | undefined;
private _followupProvider: vscode.FollowupProvider<TResult> | undefined;
private _description: string | undefined;
private _fullName: string | undefined;
Expand Down Expand Up @@ -297,7 +297,7 @@ class ExtHostChatAgent<TResult extends vscode.ChatAgentResult2> {
if (!this._slashCommandProvider) {
return [];
}
const result = await this._slashCommandProvider.provideSlashCommands(token);
const result = await this._slashCommandProvider.provideSubCommands(token);
if (!result) {
return [];
}
Expand Down Expand Up @@ -385,10 +385,10 @@ class ExtHostChatAgent<TResult extends vscode.ChatAgentResult2> {
that._iconPath = v;
updateMetadataSoon();
},
get slashCommandProvider() {
get subCommandProvider() {
return that._slashCommandProvider;
},
set slashCommandProvider(v) {
set subCommandProvider(v) {
that._slashCommandProvider = v;
updateMetadataSoon();
},
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ export namespace ChatResponseProgress {
}

export namespace ChatAgentRequest {
export function to(request: IChatAgentRequest, slashCommand: vscode.ChatAgentSlashCommand | undefined): vscode.ChatAgentRequest {
export function to(request: IChatAgentRequest, slashCommand: vscode.ChatAgentSubCommand | undefined): vscode.ChatAgentRequest {
return {
prompt: request.message,
variables: ChatVariable.objectTo(request.variables),
Expand Down
38 changes: 19 additions & 19 deletions src/vscode-dts/vscode.proposed.chatAgents2.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ declare module 'vscode' {
readonly kind: ChatAgentResultFeedbackKind;
}

export interface ChatAgentSlashCommand {
export interface ChatAgentSubCommand {
/**
* A short name by which this command is referred to in the UI, e.g. `fix` or
* `explain` for commands that fix an issue or explain code.
*
* **Note**: The name should be unique among the slash commands provided by this agent.
* **Note**: The name should be unique among the subCommands provided by this agent.
*/
readonly name: string;

Expand All @@ -98,39 +98,39 @@ declare module 'vscode' {
readonly description: string;

/**
* When the user clicks this slash command in `/help`, this text will be submitted to this slash command
* When the user clicks this subCommand in `/help`, this text will be submitted to this subCommand
*/
readonly sampleRequest?: string;

/**
* Whether executing the command puts the
* chat into a persistent mode, where the
* slash command is prepended to the chat input.
* subCommand is prepended to the chat input.
*/
readonly shouldRepopulate?: boolean;

/**
* Placeholder text to render in the chat input
* when the slash command has been repopulated.
* when the subCommand has been repopulated.
* Has no effect if `shouldRepopulate` is `false`.
*/
// TODO@API merge this with shouldRepopulate? so that invalid state cannot be represented?
readonly followupPlaceholder?: string;
}

export interface ChatAgentSlashCommandProvider {
export interface ChatAgentSubCommandProvider {

/**
* Returns a list of slash commands that its agent is capable of handling. A slash command
* Returns a list of subCommands that its agent is capable of handling. A subCommand
* can be selected by the user and will then be passed to the {@link ChatAgentHandler handler}
* via the {@link ChatAgentRequest.slashCommand slashCommand} property.
* via the {@link ChatAgentRequest.subCommand subCommand} property.
*
*
* @param token A cancellation token.
* @returns A list of slash commands. The lack of a result can be signaled by returning `undefined`, `null`, or
* @returns A list of subCommands. The lack of a result can be signaled by returning `undefined`, `null`, or
* an empty array.
*/
provideSlashCommands(token: CancellationToken): ProviderResult<ChatAgentSlashCommand[]>;
provideSubCommands(token: CancellationToken): ProviderResult<ChatAgentSubCommand[]>;
}

// TODO@API This should become a progress type, and use vscode.Command
Expand Down Expand Up @@ -208,17 +208,17 @@ declare module 'vscode' {
} | ThemeIcon;

/**
* This provider will be called to retrieve the agent's slash commands.
* This provider will be called to retrieve the agent's subCommands.
*/
slashCommandProvider?: ChatAgentSlashCommandProvider;
subCommandProvider?: ChatAgentSubCommandProvider;

/**
* This provider will be called once after each request to retrieve suggested followup questions.
*/
followupProvider?: FollowupProvider<TResult>;

/**
* When the user clicks this agent in `/help`, this text will be submitted to this slash command
* When the user clicks this agent in `/help`, this text will be submitted to this subCommand
*/
sampleRequest?: string;

Expand All @@ -240,10 +240,10 @@ declare module 'vscode' {
export interface ChatAgentRequest {

/**
* The prompt entered by the user. The {@link ChatAgent2.name name} of the agent or the {@link ChatAgentSlashCommand.name slash command}
* The prompt entered by the user. The {@link ChatAgent2.name name} of the agent or the {@link ChatAgentSubCommand.name subCommand}
* are not part of the prompt.
*
* @see {@link ChatAgentRequest.slashCommand}
* @see {@link ChatAgentRequest.subCommand}
*/
prompt: string;

Expand All @@ -253,14 +253,14 @@ declare module 'vscode' {
agentId: string;

/**
* The {@link ChatAgentSlashCommand slash command} that was selected for this request. It is guaranteed that the passed slash
* command is an instance that was previously returned from the {@link ChatAgentSlashCommandProvider.provideSlashCommands slash command provider}.
* The {@link ChatAgentSubCommand subCommand} that was selected for this request. It is guaranteed that the passed subCommand
* is an instance that was previously returned from the {@link ChatAgentSubCommandProvider.provideSubCommands subCommand provider}.
* @deprecated this will be replaced by `subCommand`
*/
slashCommand?: ChatAgentSlashCommand;
slashCommand?: ChatAgentSubCommand;

/**
* The name of the {@link ChatAgentSlashCommand slash command} that was selected for this request.
* The name of the {@link ChatAgentSubCommand subCommand} that was selected for this request.
*/
subCommand?: string;

Expand Down
2 changes: 1 addition & 1 deletion src/vscode-dts/vscode.proposed.chatAgents2Additions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare module 'vscode' {

export interface ChatAgentDetectedAgent {
agentName: string;
command?: ChatAgentSlashCommand;
command?: ChatAgentSubCommand;
}

export interface ChatAgentVulnerability {
Expand Down