Skip to content

Commit

Permalink
Adopt new static chat participant contribution (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens authored Feb 29, 2024
1 parent 1d59eca commit aa13e48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 72 deletions.
32 changes: 23 additions & 9 deletions chat-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,42 @@
},
"version": "0.1.0",
"engines": {
"vscode": "^1.86.0"
"vscode": "^1.88.0"
},
"extensionDependencies": [
"github.copilot-chat"
],
"categories": [
"Other"
],
"activationEvents": [
"onStartupFinished"
],
"activationEvents": [ ],
"enabledApiProposals": [
"chatParticipant",
"chatVariableResolver",
"chatVariableResolver",
"languageModels"
],
"contributes": {
"chatParticipants": [
{
"name": "cat",
"description": "Meow! What can I teach you?",
"commands": [
{
"name": "teach",
"description": "Pick at random a computer science concept then explain it in purfect way of a cat"
},
{
"name": "play",
"description": "Do whatever you want, you are a cat after all"
}
]
}
],
"commands": [
{
"command": "cat.namesInEditor",
"title": "Use Cat Names in Editor"
}
{
"command": "cat.namesInEditor",
"title": "Use Cat Names in Editor"
}
]
},
"main": "./out/extension.js",
Expand Down
10 changes: 0 additions & 10 deletions chat-sample/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ export function activate(context: vscode.ExtensionContext) {
const cat = vscode.chat.createChatParticipant(CAT_PARTICIPANT_NAME, handler);
cat.isSticky = true; // Cat is persistant, whenever a user starts interacting with @cat, @cat will automatically be added to the following messages
cat.iconPath = vscode.Uri.joinPath(context.extensionUri, 'cat.jpeg');
cat.description = vscode.l10n.t('Meow! What can I teach you?');
cat.commandProvider = {
provideCommands(token) {
return [
{ name: 'teach', description: 'Pick at random a computer science concept then explain it in purfect way of a cat' },
{ name: 'play', description: 'Do whatever you want, you are a cat after all' }
];
}
};

cat.followupProvider = {
provideFollowups(result: ICatChatResult, token: vscode.CancellationToken) {
return [{
Expand Down
53 changes: 0 additions & 53 deletions chat-sample/src/vscode.proposed.chatParticipant.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,49 +143,6 @@ declare module 'vscode' {
readonly kind: ChatResultFeedbackKind;
}

export interface ChatCommand {
/**
* 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 commands provided by this participant.
*/
readonly name: string;

/**
* Human-readable description explaining what this command does.
*/
readonly description: string;

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

/**
* Whether executing the command puts the chat into a persistent mode, where the command is automatically added to the chat input for the next message.
*/
readonly isSticky?: boolean;
}

/**
* A ChatCommandProvider returns {@link ChatCommands commands} that can be invoked on a chat participant using `/`. For example, `@participant /command`.
* These can be used as shortcuts to let the user explicitly invoke different functionalities provided by the participant.
*/
export interface ChatCommandProvider {
/**
* Returns a list of commands that its participant is capable of handling. A command
* can be selected by the user and will then be passed to the {@link ChatRequestHandler handler}
* via the {@link ChatRequest.command command} property.
*
*
* @param token A cancellation token.
* @returns A list of commands. The lack of a result can be signaled by returning `undefined`, `null`, or
* an empty array.
*/
provideCommands(context: ChatContext, token: CancellationToken): ProviderResult<ChatCommand[]>;
}

/**
* A followup question suggested by the participant.
*/
Expand Down Expand Up @@ -239,11 +196,6 @@ declare module 'vscode' {
*/
readonly name: string;

/**
* A human-readable description explaining what this participant does.
*/
description?: string;

/**
* Icon for the participant shown in UI.
*/
Expand All @@ -263,11 +215,6 @@ declare module 'vscode' {
*/
requestHandler: ChatRequestHandler;

/**
* This provider will be called to retrieve the participant's commands.
*/
commandProvider?: ChatCommandProvider;

/**
* This provider will be called once after each request to retrieve suggested followup questions.
*/
Expand Down

0 comments on commit aa13e48

Please sign in to comment.