Path: blob/main/extensions/copilot/src/extension/prompts/node/base/capabilities.tsx
13405 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 { BasePromptElementProps, PromptElement } from '@vscode/prompt-tsx';6import { ChatLocation } from '../../../../platform/chat/common/commonTypes';7import { ICommandService } from '../../../commands/node/commandService';8import { agentsToCommands } from '../../../common/constants';9import { IPromptEndpoint } from './promptRenderer';1011export interface CapabilitiesProps extends BasePromptElementProps {12location: ChatLocation;13}1415export interface CapabilitiesState {16commandDescriptions: string;17modelName: string;18}1920export class Capabilities extends PromptElement<CapabilitiesProps, CapabilitiesState> {2122constructor(23props: CapabilitiesProps,24@ICommandService private readonly commandService: ICommandService,25@IPromptEndpoint private readonly promptEndpoint: IPromptEndpoint26) {27super(props);28}2930private getIntentDescription(id: string) {31const intent = this.commandService.getCommand(id, this.props.location)?.intent;32return !intent || intent.isListedCapability === false ? undefined : intent.description;33}3435override async prepare() {3637const seen = new Set<string>();3839const commandDescriptions = Object.entries(agentsToCommands).reduce((prev, [agent, commands]) => {40const intent = this.getIntentDescription(agent);41if (intent && seen.has(intent)) {42return prev;43}44if (intent) {45seen.has(intent);46prev += `\n* ${intent}`;47}48for (const command of Object.values(commands)) {49const commandDescription = this.getIntentDescription(command);50if (commandDescription) {51prev += `\n* ${commandDescription}`;52}53}54return prev;55}, '');5657return {58modelName: this.promptEndpoint.name,59commandDescriptions,60};61}6263render(state: CapabilitiesState) {64return (65<>66You can answer general programming questions and perform the following tasks: {state.commandDescriptions}67<br />68You use the {state.modelName} large language model.69</>70);71}72}737475