Path: blob/main/extensions/copilot/src/extension/intents/node/unknownIntent.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as l10n from '@vscode/l10n';6import { ChatLocation } from '../../../platform/chat/common/commonTypes';7import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';8import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';9import { Intent } from '../../common/constants';10import { GenericInlineIntentInvocation } from '../../context/node/resolvers/genericInlineIntentInvocation';11import { GenericPanelIntentInvocation } from '../../context/node/resolvers/genericPanelIntentInvocation';12import { EditStrategy } from '../../prompt/node/editGeneration';13import { IIntent, IIntentInvocation, IIntentInvocationContext, IIntentSlashCommandInfo } from '../../prompt/node/intents';141516export class UnknownIntent implements IIntent {1718static readonly ID = Intent.Unknown;1920readonly id = UnknownIntent.ID;21readonly locations = [ChatLocation.Editor, ChatLocation.Panel];22readonly description = l10n.t('Intent of this command is unclear or is not related to information technologies');23readonly commandInfo: IIntentSlashCommandInfo = { hiddenFromUser: true };2425constructor(26@IInstantiationService private readonly instantiationService: IInstantiationService,27@IEndpointProvider private readonly endpointProvider: IEndpointProvider,28) { }2930async invoke(invocationContext: IIntentInvocationContext): Promise<IIntentInvocation> {31const { location, documentContext, request } = invocationContext;32const endpoint = await this.endpointProvider.getChatEndpoint(request);33if (location === ChatLocation.Editor) {34if (!documentContext) {35throw new Error('Open a file to add code.');36}37return this.instantiationService.createInstance(GenericInlineIntentInvocation, this, location, endpoint, documentContext, EditStrategy.FallbackToReplaceRange);38}39return this.instantiationService.createInstance(GenericPanelIntentInvocation, this, location, endpoint, undefined, documentContext);40}41}424344