Path: blob/main/extensions/copilot/src/extension/intents/node/searchPanelIntent.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 type * as vscode from 'vscode';7import { ChatLocation } from '../../../platform/chat/common/commonTypes';8import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';9import { IChatEndpoint } from '../../../platform/networking/common/networking';10import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';11import { Intent } from '../../common/constants';12import { IIntent, IIntentInvocation, IIntentInvocationContext, IIntentSlashCommandInfo } from '../../prompt/node/intents';13import { PromptRenderer, RendererIntentInvocation } from '../../prompts/node/base/promptRenderer';14import { ISearchPanelPromptContext, SearchPanelPrompt } from '../../prompts/node/panel/searchPanelPrompt';151617class SearchIntentInvocation extends RendererIntentInvocation implements IIntentInvocation {1819constructor(20intent: IIntent,21location: ChatLocation,22endpoint: IChatEndpoint,23@IInstantiationService private readonly instantiationService: IInstantiationService,24) {25super(intent, location, endpoint);26}2728createRenderer(promptContext: ISearchPanelPromptContext, endpoint: IChatEndpoint, progress: vscode.Progress<vscode.ChatResponseProgressPart | vscode.ChatResponseReferencePart>, token: vscode.CancellationToken) {29return PromptRenderer.create(this.instantiationService, endpoint, SearchPanelPrompt, {30promptContext,31endpoint32});33}34}3536export class SearchPanelIntent implements IIntent {37static readonly ID = Intent.SearchPanel;3839readonly id = SearchPanelIntent.ID;4041readonly description = l10n.t('Search code in your current workspace');4243readonly locations = [ChatLocation.Other];4445readonly commandInfo: IIntentSlashCommandInfo = {46allowsEmptyArgs: false,47defaultEnablement: true,48};4950constructor(51@IInstantiationService private readonly instantiationService: IInstantiationService,52@IEndpointProvider private readonly endpointProvider: IEndpointProvider,53) { }5455async invoke(invocationContext: IIntentInvocationContext): Promise<IIntentInvocation> {56const location = invocationContext.location;57const endpoint = await this.endpointProvider.getChatEndpoint('copilot-base');58return this.instantiationService.createInstance(SearchIntentInvocation, this, location, endpoint);59}60}616263