Path: blob/main/extensions/copilot/src/extension/prompts/node/panel/terminalExplain.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, PromptPiece, SystemMessage, UserMessage } from '@vscode/prompt-tsx';6import { IChatEndpoint } from '../../../../platform/networking/common/networking';7import { IBuildPromptContext } from '../../../prompt/common/intents';8import { CopilotIdentityRules } from '../base/copilotIdentity';9import { InstructionMessage } from '../base/instructionMessage';10import { ResponseTranslationRules } from '../base/responseTranslationRules';11import { SafetyRules } from '../base/safetyRules';12import { ChatToolReferences, ChatVariablesAndQuery } from './chatVariables';13import { HistoryWithInstructions } from './conversationHistory';14import { CustomInstructions } from './customInstructions';15import { EditorIntegrationRules } from './editorIntegrationRules';16import { TerminalLastCommand } from './terminalLastCommand';17import { TerminalSelection } from './terminalSelection';1819export interface TerminalPromptProps extends BasePromptElementProps {20promptContext: IBuildPromptContext;21osName: string;22shellType: string;23endpoint: IChatEndpoint;24}2526export interface TerminalPromptState {27}2829export class TerminalExplainPrompt extends PromptElement<TerminalPromptProps, TerminalPromptState> {3031override render(state: TerminalPromptState): PromptPiece<any, any> | undefined {32const { history, chatVariables, } = this.props.promptContext;33const query = this.props.promptContext.query || 'What did the last command do?';34return (35<>36<SystemMessage priority={1000}>37You are a programmer who specializes in using the command line. Your task is to help the Developer by giving a detailed answer to their query.<br />38<CopilotIdentityRules />39<SafetyRules />40</SystemMessage>41<HistoryWithInstructions flexGrow={1} historyPriority={600} passPriority history={history}>42<InstructionMessage priority={1000}>43<EditorIntegrationRules />44<ResponseTranslationRules />45<br />46Additional Rules<br />47{`Generate a response that clearly and accurately answers the user's question. In your response, follow the following:48- Provide any command suggestions using the active shell and operating system.49- Say "I'm not quite sure how to do that." when you aren't confident in your explanation`}<br />50</InstructionMessage>51</HistoryWithInstructions>52<UserMessage flexGrow={1} priority={750}>53<CustomInstructions languageId={undefined} chatVariables={chatVariables} />54</UserMessage>55<UserMessage flexGrow={1} priority={800}>56The active terminal's shell type is:<br />57{this.props.shellType}58</UserMessage >59<UserMessage flexGrow={1} priority={800}>60The active operating system is:<br />61{this.props.osName}62</UserMessage >63<TerminalSelection flexGrow={1} priority={800} />64<TerminalLastCommand flexGrow={1} priority={800} />65<ChatToolReferences priority={899} flexGrow={2} promptContext={this.props.promptContext} embeddedInsideUserMessage={false} />66<ChatVariablesAndQuery flexGrow={2} priority={900} chatVariables={chatVariables} query={query} embeddedInsideUserMessage={false} />67</>68);69}70}717273