Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompts/node/feedback/provideFeedback.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
import { BasePromptElementProps, PromptElement, PromptPiece, PromptSizing, SystemMessage, UserMessage } from '@vscode/prompt-tsx';
6
import { ILogService } from '../../../../platform/log/common/logService';
7
import { ChatVariablesCollection } from '../../../prompt/common/chatVariablesCollection';
8
import { Turn } from '../../../prompt/common/conversation';
9
import { CopilotIdentityRules } from '../base/copilotIdentity';
10
import { ResponseTranslationRules } from '../base/responseTranslationRules';
11
import { SafetyRules } from '../base/safetyRules';
12
import { ChatVariablesAndQuery } from '../panel/chatVariables';
13
import { CustomInstructions } from '../panel/customInstructions';
14
import { EditorIntegrationRules } from '../panel/editorIntegrationRules';
15
import { ProjectLabels } from '../panel/projectLabels';
16
import { SymbolDefinitions } from '../panel/symbolDefinitions';
17
import { CurrentChange, CurrentChangeInput } from './currentChange';
18
19
export interface ProvideFeedbackPromptProps extends BasePromptElementProps {
20
chatVariables?: ChatVariablesCollection;
21
history?: readonly Turn[];
22
query?: string;
23
24
input: CurrentChangeInput[];
25
logService: ILogService;
26
}
27
28
export class ProvideFeedbackPrompt extends PromptElement<ProvideFeedbackPromptProps> {
29
30
override render(state: void, sizing: PromptSizing): PromptPiece<any, any> | undefined {
31
return (
32
<>
33
<SystemMessage priority={1001}>
34
You are a world-class software engineer and the author and maintainer of the discussed code. Your feedback prefectly combines detailed feedback and explanation of context.<br />
35
<CopilotIdentityRules />
36
<SafetyRules />
37
<EditorIntegrationRules />
38
<ResponseTranslationRules />
39
<br />
40
Additional Rules<br />
41
Think step by step:<br />
42
1. Examine the provided code and any other context like user question, related errors, project details, class definitions, etc.<br />
43
2. Provide feedback on the current {this.props.input[0]?.change ? <>change</> : <>selection</>} on where it can be improved or introduces a problem.<br />
44
2a. Avoid commenting on correct code.<br />
45
2b. Avoid commenting on commented out code.<br />
46
2c. Keep scoping rules in mind.<br />
47
3. Reply with an enumerated list of feedback with source line number, filepath, kind (bug, performance, consistency, documentation, naming, readability, style, other), severity (low, medium, high), and feedback text.<br />
48
3a. E.g.: 1. Line 357 in src/flow.js, bug, high severity: `i` is not incremented.<br />
49
3b. E.g.: 2. Line 361 in src/arrays.js, documentation, low severity: Function `binarySearch` is not documented.<br />
50
3c. E.g.: 3. Line 176 in src/vs/platform/actionWidget/browser/actionWidget.ts, consistency, medium severity: The color id `'background.actionBar'` is not consistent with the other color ids used. Use `'actionBar.background'` instead.<br />
51
3d. E.g.: 4. Line 410 in src/search.js, documentation, medium severity: Returning `-1` when the target is not found is a common convention, but it should be documented.<br />
52
3e. E.g.: 5. Line 51 in src/account.py, bug, high severity: The deposit method is not thread-safe. You should use a lock to ensure that the balance update is an atomic operation.<br />
53
3f. E.g.: 6. Line 220 in src/account.py, readability, low severity: The withdraw method is very long and combines multipe logical steps, consider splitting it into multiple methods.<br />
54
4. Try to sort the feedback by file and line number.<br />
55
5. When there is no feedback to provide, reply with "No feedback to provide."<br />
56
<br />
57
Focus on being clear, helpful, and thorough.<br />
58
Use developer-friendly terms and analogies in your explanations.<br />
59
Provide clear and relevant examples when helpful.
60
</SystemMessage>
61
{/* {this.props.history && <><ConversationHistory priority={600} history={this.props.history} /></>} */}
62
<UserMessage flexGrow={1}>
63
<ProjectLabels flexGrow={1} priority={700} />
64
<CustomInstructions chatVariables={this.props.chatVariables} priority={850} languageId={this.props.input[0]?.document.languageId} customIntroduction={'When providing feedback for code, please check for these user provided coding guidelines.'} includeCodeFeedbackInstructions={true} />
65
<CurrentChange input={this.props.input} logService={this.props.logService} priority={1000} flexGrow={2} />
66
{
67
this.props.input.map(input => (
68
<SymbolDefinitions document={input.document} range={input.selection} priority={800} />
69
))
70
}
71
{this.props.chatVariables && this.props.query && <ChatVariablesAndQuery flexGrow={3} priority={900} chatVariables={this.props.chatVariables} query={this.props.query} />}
72
</UserMessage>
73
</>
74
);
75
}
76
}
77
78