mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-19 14:22:19 +01:00
fix: pick up intent detection metadata for chat commands (#225519)
* fix: pick up intent detection metadata for chat commands * Make command disambiguation optional * Make disambiguation collection more readable
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { coalesce, isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { Disposable, DisposableMap, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
@@ -240,6 +240,22 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
|
||||
store.add(this.registerDefaultParticipantView(providerDescriptor));
|
||||
}
|
||||
|
||||
const participantsAndCommandsDisambiguation: {
|
||||
categoryName: string;
|
||||
description: string;
|
||||
examples: string[];
|
||||
}[] = [];
|
||||
if (providerDescriptor.disambiguation?.length) {
|
||||
participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation);
|
||||
}
|
||||
if (providerDescriptor.commands) {
|
||||
for (const command of providerDescriptor.commands) {
|
||||
if (command.disambiguation?.length) {
|
||||
participantsAndCommandsDisambiguation.push(...command.disambiguation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
store.add(this._chatAgentService.registerAgent(
|
||||
providerDescriptor.id,
|
||||
{
|
||||
@@ -261,7 +277,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
|
||||
providerDescriptor.locations.map(ChatAgentLocation.fromRaw) :
|
||||
[ChatAgentLocation.Panel],
|
||||
slashCommands: providerDescriptor.commands ?? [],
|
||||
disambiguation: providerDescriptor.disambiguation ?? [],
|
||||
disambiguation: coalesce(participantsAndCommandsDisambiguation.flat()),
|
||||
} satisfies IChatAgentData));
|
||||
|
||||
this._participantRegistrationDisposables.set(
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface IRawChatCommandContribution {
|
||||
isSticky?: boolean;
|
||||
when?: string;
|
||||
defaultImplicitVariables?: string[];
|
||||
disambiguation?: { categoryName: string; description: string; examples: string[] }[];
|
||||
}
|
||||
|
||||
export type RawChatParticipantLocation = 'panel' | 'terminal' | 'notebook';
|
||||
@@ -26,7 +27,7 @@ export interface IRawChatParticipantContribution {
|
||||
commands?: IRawChatCommandContribution[];
|
||||
defaultImplicitVariables?: string[];
|
||||
locations?: RawChatParticipantLocation[];
|
||||
disambiguation: { categoryName: string; description: string; examples: string[] }[];
|
||||
disambiguation?: { categoryName: string; description: string; examples: string[] }[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user