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