Path: blob/main/extensions/copilot/src/extension/intents/node/setupTests.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 { isPreRelease } from '../../../platform/env/common/packagejson';9import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';10import { Intent } from '../../common/constants';11import { IIntent, IIntentInvocation, IIntentInvocationContext, IIntentSlashCommandInfo } from '../../prompt/node/intents';12import { SetupTestsFrameworkQueryInvocation } from './testIntent/setupTestsFrameworkQueryInvocation';13import { SetupTestsInvocation } from './testIntent/setupTestsInvocation';141516export class SetupTestsIntent implements IIntent {17static readonly ID = Intent.SetupTests;18readonly id = SetupTestsIntent.ID;19readonly locations = [ChatLocation.Panel];20readonly description = l10n.t('Set up Tests');21readonly isListedCapability = false;2223readonly commandInfo: IIntentSlashCommandInfo = {24allowsEmptyArgs: true,25defaultEnablement: isPreRelease,26};2728constructor(29@IEndpointProvider private readonly endpointProvider: IEndpointProvider,30@IInstantiationService private readonly instantiationService: IInstantiationService,31) { }3233async invoke(invocationContext: IIntentInvocationContext): Promise<IIntentInvocation> {34const endpoint = await this.endpointProvider.getChatEndpoint(invocationContext.request);3536let prompt = invocationContext.request.prompt;37if (invocationContext.request.acceptedConfirmationData) {38// todo@connor4312: VS Code currently creates a prompt like `${choice}: "${Confirmation Message}"`39// and so we parse the choice back out of three40// note: intentionally not localized as this is used as a prompt instruction:41prompt = `set up tests in my workspace using \`${prompt.split(':')[0]}\``;42}4344if (!prompt) {45return this.instantiationService.createInstance(SetupTestsFrameworkQueryInvocation, this, endpoint, invocationContext.location, invocationContext.documentContext);46}4748return Promise.resolve(this.instantiationService.createInstance(SetupTestsInvocation, this, endpoint, invocationContext.location, prompt));49}50}515253