Skip to content

Commit e04b497

Browse files
committed
Updates prompts for AI generating messages
1 parent efeefb8 commit e04b497

File tree

7 files changed

+50
-16
lines changed

7 files changed

+50
-16
lines changed

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,9 +3536,16 @@
35363536
"scope": "window",
35373537
"order": 2
35383538
},
3539-
"gitlens.experimental.generateDraftMessagePrompt": {
3539+
"gitlens.experimental.generateCloudPatchMessagePrompt": {
35403540
"type": "string",
3541-
"default": "Now, please generate a commit message. Ensure that it includes a precise and informative subject line that succinctly summarizes the crux of the changes in under 50 characters. If necessary, follow with an explanatory body providing insight into the nature of the changes, the reasoning behind them, and any significant consequences or considerations arising from them. Conclude with any relevant issue references at the end of the message.",
3541+
"default": "Now, please generate a title and optional description. Ensure that it includes a precise and informative subject line that succinctly summarizes the crux of the changes in under 50 characters. If necessary, follow with an explanatory body providing insight into the nature of the changes, the reasoning behind them, and any significant consequences or considerations arising from them. Conclude with any relevant issue references at the end of the message.",
3542+
"markdownDescription": "Specifies the prompt to use to tell the AI provider how to structure or format the generated title and description",
3543+
"scope": "window",
3544+
"order": 3
3545+
},
3546+
"gitlens.experimental.generateCodeSuggestMessagePrompt": {
3547+
"type": "string",
3548+
"default": "Now, please generate a title and optional description. Ensure that it includes a precise and informative subject line that succinctly summarizes the crux of the changes in under 50 characters. If necessary, follow with an explanatory body providing insight into the nature of the changes, the reasoning behind them, and any significant consequences or considerations arising from them. Conclude with any relevant issue references at the end of the message.",
35423549
"markdownDescription": "Specifies the prompt to use to tell the AI provider how to structure or format the generated title and description",
35433550
"scope": "window",
35443551
"order": 3

src/ai/anthropicProvider.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { configuration } from '../system/configuration';
77
import type { Storage } from '../system/storage';
88
import type { AIModel, AIProvider } from './aiProviderService';
99
import { getApiKey as getApiKeyCore, getMaxCharacters } from './aiProviderService';
10-
import { commitMessageSystemPrompt, draftMessageSystemPrompt } from './prompts';
10+
import { cloudPatchMessageSystemPrompt, codeSuggestMessageSystemPrompt, commitMessageSystemPrompt } from './prompts';
1111

1212
const provider = { id: 'anthropic', name: 'Anthropic' } as const;
1313
type LegacyModels = Extract<AnthropicModels, 'claude-instant-1' | 'claude-2'>;
@@ -173,7 +173,10 @@ export class AnthropicProvider implements AIProvider<typeof provider.id> {
173173
diff: string,
174174
options?: { cancellation?: CancellationToken; context?: string; codeSuggestion?: boolean },
175175
): Promise<string | undefined> {
176-
let customPrompt = configuration.get('experimental.generateDraftMessagePrompt');
176+
let customPrompt =
177+
options?.codeSuggestion === true
178+
? configuration.get('experimental.generateCodeSuggestionMessagePrompt')
179+
: configuration.get('experimental.generateCloudPatchMessagePrompt');
177180
if (!customPrompt.endsWith('.')) {
178181
customPrompt += '.';
179182
}
@@ -182,7 +185,8 @@ export class AnthropicProvider implements AIProvider<typeof provider.id> {
182185
model,
183186
diff,
184187
{
185-
systemPrompt: draftMessageSystemPrompt,
188+
systemPrompt:
189+
options?.codeSuggestion === true ? codeSuggestMessageSystemPrompt : cloudPatchMessageSystemPrompt,
186190
customPrompt: customPrompt,
187191
contextName:
188192
options?.codeSuggestion === true

src/ai/geminiProvider.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { configuration } from '../system/configuration';
77
import type { Storage } from '../system/storage';
88
import type { AIModel, AIProvider } from './aiProviderService';
99
import { getApiKey as getApiKeyCore, getMaxCharacters } from './aiProviderService';
10-
import { commitMessageSystemPrompt, draftMessageSystemPrompt } from './prompts';
10+
import { cloudPatchMessageSystemPrompt, codeSuggestMessageSystemPrompt, commitMessageSystemPrompt } from './prompts';
1111

1212
const provider = { id: 'gemini', name: 'Google' } as const;
1313

@@ -140,7 +140,10 @@ export class GeminiProvider implements AIProvider<typeof provider.id> {
140140
codeSuggestion?: boolean | undefined;
141141
},
142142
): Promise<string | undefined> {
143-
let customPrompt = configuration.get('experimental.generateDraftMessagePrompt');
143+
let customPrompt =
144+
options?.codeSuggestion === true
145+
? configuration.get('experimental.generateCodeSuggestionMessagePrompt')
146+
: configuration.get('experimental.generateCloudPatchMessagePrompt');
144147
if (!customPrompt.endsWith('.')) {
145148
customPrompt += '.';
146149
}
@@ -149,7 +152,8 @@ export class GeminiProvider implements AIProvider<typeof provider.id> {
149152
model,
150153
diff,
151154
{
152-
systemPrompt: draftMessageSystemPrompt,
155+
systemPrompt:
156+
options?.codeSuggestion === true ? codeSuggestMessageSystemPrompt : cloudPatchMessageSystemPrompt,
153157
customPrompt: customPrompt,
154158
contextName:
155159
options?.codeSuggestion === true

src/ai/openaiProvider.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { configuration } from '../system/configuration';
77
import type { Storage } from '../system/storage';
88
import type { AIModel, AIProvider } from './aiProviderService';
99
import { getApiKey as getApiKeyCore, getMaxCharacters } from './aiProviderService';
10-
import { commitMessageSystemPrompt, draftMessageSystemPrompt } from './prompts';
10+
import { cloudPatchMessageSystemPrompt, codeSuggestMessageSystemPrompt, commitMessageSystemPrompt } from './prompts';
1111

1212
const provider = { id: 'openai', name: 'OpenAI' } as const;
1313

@@ -237,7 +237,10 @@ export class OpenAIProvider implements AIProvider<typeof provider.id> {
237237
codeSuggestion?: boolean | undefined;
238238
},
239239
): Promise<string | undefined> {
240-
let customPrompt = configuration.get('experimental.generateDraftMessagePrompt');
240+
let customPrompt =
241+
options?.codeSuggestion === true
242+
? configuration.get('experimental.generateCodeSuggestionMessagePrompt')
243+
: configuration.get('experimental.generateCloudPatchMessagePrompt');
241244
if (!customPrompt.endsWith('.')) {
242245
customPrompt += '.';
243246
}
@@ -246,7 +249,8 @@ export class OpenAIProvider implements AIProvider<typeof provider.id> {
246249
model,
247250
diff,
248251
{
249-
systemPrompt: draftMessageSystemPrompt,
252+
systemPrompt:
253+
options?.codeSuggestion === true ? codeSuggestMessageSystemPrompt : cloudPatchMessageSystemPrompt,
250254
customPrompt: customPrompt,
251255
contextName:
252256
options?.codeSuggestion === true

src/ai/prompts.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ export const commitMessageSystemPrompt = `You are an advanced AI programming ass
88
99
Follow the user's instructions carefully, don't repeat yourself, don't include the code in the output, or make anything up!`;
1010

11-
export const draftMessageSystemPrompt = `You are an advanced AI programming assistant tasked with summarizing code changes into a concise and meaningful commit message. Compose a commit message that:
11+
export const cloudPatchMessageSystemPrompt = `You are an advanced AI programming assistant tasked with summarizing code changes into a concise and meaningful title with an optional description. Compose a title with an optional description that:
12+
- Strictly synthesizes meaningful information from the provided code diff
13+
- Utilizes any additional user-provided context to comprehend the rationale behind the code changes
14+
- Is clear and brief, with an informal yet professional tone, and without superfluous descriptions
15+
- Avoids unnecessary phrases such as "this commit", "this change", and the like
16+
- Avoids direct mention of specific code identifiers, names, or file names, unless they are crucial for understanding the purpose of the changes
17+
- Most importantly emphasizes the 'why' of the change, its benefits, or the problem it addresses rather than only the 'what' that changed
18+
19+
Follow the user's instructions carefully, don't repeat yourself, don't include the code in the output, or make anything up!`;
20+
21+
export const codeSuggestMessageSystemPrompt = `You are an advanced AI programming assistant tasked with summarizing code changes into a concise and meaningful code review title with an optional description. Compose a code review title with an optional description that:
1222
- Strictly synthesizes meaningful information from the provided code diff
1323
- Utilizes any additional user-provided context to comprehend the rationale behind the code changes
1424
- Is clear and brief, with an informal yet professional tone, and without superfluous descriptions

src/ai/vscodeProvider.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { configuration } from '../system/configuration';
55
import { capitalize } from '../system/string';
66
import type { AIModel, AIProvider } from './aiProviderService';
77
import { getMaxCharacters } from './aiProviderService';
8-
import { commitMessageSystemPrompt, draftMessageSystemPrompt } from './prompts';
8+
import { cloudPatchMessageSystemPrompt, codeSuggestMessageSystemPrompt, commitMessageSystemPrompt } from './prompts';
99

1010
const provider = { id: 'vscode', name: 'VS Code Provided' } as const;
1111

@@ -133,7 +133,10 @@ export class VSCodeAIProvider implements AIProvider<typeof provider.id> {
133133
codeSuggestion?: boolean | undefined;
134134
},
135135
): Promise<string | undefined> {
136-
let customPrompt = configuration.get('experimental.generateDraftMessagePrompt');
136+
let customPrompt =
137+
options?.codeSuggestion === true
138+
? configuration.get('experimental.generateCodeSuggestionMessagePrompt')
139+
: configuration.get('experimental.generateCloudPatchMessagePrompt');
137140
if (!customPrompt.endsWith('.')) {
138141
customPrompt += '.';
139142
}
@@ -142,7 +145,8 @@ export class VSCodeAIProvider implements AIProvider<typeof provider.id> {
142145
model,
143146
diff,
144147
{
145-
systemPrompt: draftMessageSystemPrompt,
148+
systemPrompt:
149+
options?.codeSuggestion === true ? codeSuggestMessageSystemPrompt : cloudPatchMessageSystemPrompt,
146150
customPrompt: customPrompt,
147151
contextName:
148152
options?.codeSuggestion === true

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export interface Config {
8080
readonly detectNestedRepositories: boolean;
8181
readonly experimental: {
8282
readonly generateCommitMessagePrompt: string;
83-
readonly generateDraftMessagePrompt: string;
83+
readonly generateCloudPatchMessagePrompt: string;
84+
readonly generateCodeSuggestionMessagePrompt: string;
8485
};
8586
readonly fileAnnotations: {
8687
readonly preserveWhileEditing: boolean;

0 commit comments

Comments
 (0)