Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/intents/node/searchPanelIntent.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 type * as vscode from 'vscode';
8
import { ChatLocation } from '../../../platform/chat/common/commonTypes';
9
import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
10
import { IChatEndpoint } from '../../../platform/networking/common/networking';
11
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
12
import { Intent } from '../../common/constants';
13
import { IIntent, IIntentInvocation, IIntentInvocationContext, IIntentSlashCommandInfo } from '../../prompt/node/intents';
14
import { PromptRenderer, RendererIntentInvocation } from '../../prompts/node/base/promptRenderer';
15
import { ISearchPanelPromptContext, SearchPanelPrompt } from '../../prompts/node/panel/searchPanelPrompt';
16
17
18
class SearchIntentInvocation extends RendererIntentInvocation implements IIntentInvocation {
19
20
constructor(
21
intent: IIntent,
22
location: ChatLocation,
23
endpoint: IChatEndpoint,
24
@IInstantiationService private readonly instantiationService: IInstantiationService,
25
) {
26
super(intent, location, endpoint);
27
}
28
29
createRenderer(promptContext: ISearchPanelPromptContext, endpoint: IChatEndpoint, progress: vscode.Progress<vscode.ChatResponseProgressPart | vscode.ChatResponseReferencePart>, token: vscode.CancellationToken) {
30
return PromptRenderer.create(this.instantiationService, endpoint, SearchPanelPrompt, {
31
promptContext,
32
endpoint
33
});
34
}
35
}
36
37
export class SearchPanelIntent implements IIntent {
38
static readonly ID = Intent.SearchPanel;
39
40
readonly id = SearchPanelIntent.ID;
41
42
readonly description = l10n.t('Search code in your current workspace');
43
44
readonly locations = [ChatLocation.Other];
45
46
readonly commandInfo: IIntentSlashCommandInfo = {
47
allowsEmptyArgs: false,
48
defaultEnablement: true,
49
};
50
51
constructor(
52
@IInstantiationService private readonly instantiationService: IInstantiationService,
53
@IEndpointProvider private readonly endpointProvider: IEndpointProvider,
54
) { }
55
56
async invoke(invocationContext: IIntentInvocationContext): Promise<IIntentInvocation> {
57
const location = invocationContext.location;
58
const endpoint = await this.endpointProvider.getChatEndpoint('copilot-base');
59
return this.instantiationService.createInstance(SearchIntentInvocation, this, location, endpoint);
60
}
61
}
62
63