Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/intents/node/setupTests.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as l10n from '@vscode/l10n';
7
import { ChatLocation } from '../../../platform/chat/common/commonTypes';
8
import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
9
import { isPreRelease } from '../../../platform/env/common/packagejson';
10
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
11
import { Intent } from '../../common/constants';
12
import { IIntent, IIntentInvocation, IIntentInvocationContext, IIntentSlashCommandInfo } from '../../prompt/node/intents';
13
import { SetupTestsFrameworkQueryInvocation } from './testIntent/setupTestsFrameworkQueryInvocation';
14
import { SetupTestsInvocation } from './testIntent/setupTestsInvocation';
15
16
17
export class SetupTestsIntent implements IIntent {
18
static readonly ID = Intent.SetupTests;
19
readonly id = SetupTestsIntent.ID;
20
readonly locations = [ChatLocation.Panel];
21
readonly description = l10n.t('Set up Tests');
22
readonly isListedCapability = false;
23
24
readonly commandInfo: IIntentSlashCommandInfo = {
25
allowsEmptyArgs: true,
26
defaultEnablement: isPreRelease,
27
};
28
29
constructor(
30
@IEndpointProvider private readonly endpointProvider: IEndpointProvider,
31
@IInstantiationService private readonly instantiationService: IInstantiationService,
32
) { }
33
34
async invoke(invocationContext: IIntentInvocationContext): Promise<IIntentInvocation> {
35
const endpoint = await this.endpointProvider.getChatEndpoint(invocationContext.request);
36
37
let prompt = invocationContext.request.prompt;
38
if (invocationContext.request.acceptedConfirmationData) {
39
// todo@connor4312: VS Code currently creates a prompt like `${choice}: "${Confirmation Message}"`
40
// and so we parse the choice back out of three
41
// note: intentionally not localized as this is used as a prompt instruction:
42
prompt = `set up tests in my workspace using \`${prompt.split(':')[0]}\``;
43
}
44
45
if (!prompt) {
46
return this.instantiationService.createInstance(SetupTestsFrameworkQueryInvocation, this, endpoint, invocationContext.location, invocationContext.documentContext);
47
}
48
49
return Promise.resolve(this.instantiationService.createInstance(SetupTestsInvocation, this, endpoint, invocationContext.location, prompt));
50
}
51
}
52
53