Skip to content

Commit 1d9a64a

Browse files
feat(commit-message): add prompt template and generator service
Part 2 of 4 for AI commit-message generation. Adds the model-facing half: a customizable prompt and a service that turns git context into a message. No command or UI wires it up yet. - Registers COMMIT_MESSAGE in `support-prompt.ts` alongside ENHANCE. Because the Prompts settings tab iterates the support-prompt registry, this gives the template an editor and a reset button without any new UI code. The default asks for Conventional Commits and tells the model to account for every changed file; without that instruction models describe the largest file and silently drop the rest. - Adds `commitMessageApiConfigId` so a small, fast profile can be used for this task. Mirrors `enhancementApiConfigId`, including the `listApiConfigMeta` guard before `getProfile()` so a deleted profile falls back to the active configuration rather than throwing. - Adds `generateCommitMessage()`, which resolves the repository from the git extension API, collects context, and writes the cleaned result into the SCM input box. Models wrap answers in fences and quotes despite instruction, so the response is stripped before use. Progress is reported at `ProgressLocation.Window`; `SourceControl` drops the title, and no location renders a cancel button that would work, since nearly every provider ignores `completePrompt`'s abort signal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 6b955f0 commit 1d9a64a

42 files changed

Lines changed: 467 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/types/src/global-settings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export const globalSettingsSchema = z.object({
235235
customSupportPrompts: customSupportPromptsSchema.optional(),
236236
enhancementApiConfigId: z.string().optional(),
237237
includeTaskHistoryInEnhance: z.boolean().optional(),
238+
commitMessageApiConfigId: z.string().optional(),
238239
historyPreviewCollapsed: z.boolean().optional(),
239240
reasoningBlockCollapsed: z.boolean().optional(),
240241
/**

‎packages/types/src/vscode-extension-host.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export type ExtensionState = Pick<
304304
| "customModePrompts"
305305
| "customSupportPrompts"
306306
| "enhancementApiConfigId"
307+
| "commitMessageApiConfigId"
307308
| "customCondensingPrompt"
308309
| "codebaseIndexConfig"
309310
| "codebaseIndexModels"

‎src/core/webview/ClineProvider.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,6 +2461,7 @@ export class ClineProvider
24612461
customModePrompts,
24622462
customSupportPrompts,
24632463
enhancementApiConfigId,
2464+
commitMessageApiConfigId,
24642465
autoApprovalEnabled,
24652466
customModes,
24662467
experiments,
@@ -2619,6 +2620,7 @@ export class ClineProvider
26192620
customModePrompts: customModePrompts ?? {},
26202621
customSupportPrompts: customSupportPrompts ?? {},
26212622
enhancementApiConfigId,
2623+
commitMessageApiConfigId,
26222624
autoApprovalEnabled: autoApprovalEnabled ?? false,
26232625
customModes,
26242626
experiments: experiments ?? experimentDefault,
@@ -2852,6 +2854,7 @@ export class ClineProvider
28522854
customModePrompts: stateValues.customModePrompts ?? {},
28532855
customSupportPrompts: stateValues.customSupportPrompts ?? {},
28542856
enhancementApiConfigId: stateValues.enhancementApiConfigId,
2857+
commitMessageApiConfigId: stateValues.commitMessageApiConfigId,
28552858
experiments: stateValues.experiments ?? experimentDefault,
28562859
autoApprovalEnabled: stateValues.autoApprovalEnabled ?? false,
28572860
customModes,

‎src/i18n/locales/ca/common.json‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/i18n/locales/de/common.json‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/i18n/locales/en/common.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"update_support_prompt": "Failed to update support prompt",
4141
"reset_support_prompt": "Failed to reset support prompt",
4242
"enhance_prompt": "Failed to enhance prompt",
43+
"commit_message_no_repository": "No Git repository found in the Source Control panel.",
44+
"commit_message_failed": "Failed to generate commit message: {{error}}",
4345
"get_system_prompt": "Failed to get system prompt",
4446
"search_commits": "Failed to search commits",
4547
"save_api_config": "Failed to save api configuration",
@@ -160,6 +162,8 @@
160162
},
161163
"info": {
162164
"no_changes": "No changes found.",
165+
"commit_message_generating": "Generating commit message...",
166+
"commit_message_no_changes": "No changes to commit.",
163167
"clipboard_copy": "System prompt successfully copied to clipboard",
164168
"history_cleanup": "Cleaned up {{count}} task(s) with missing files from history.",
165169
"custom_storage_path_set": "Custom storage path set: {{path}}",

‎src/i18n/locales/es/common.json‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/i18n/locales/fr/common.json‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/i18n/locales/hi/common.json‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/i18n/locales/id/common.json‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)