From 0261ec28926d27b9023e4b13bca05c5d56c60c99 Mon Sep 17 00:00:00 2001 From: Shirone Date: Mon, 12 Jan 2026 20:48:08 +0100 Subject: [PATCH] feat(prompts): implement customizable commit message prompts - Added a new section in the UI for customizing commit message prompts. - Integrated a system prompt for AI-generated commit messages, allowing users to define their own instructions. - Updated the backend to merge custom prompts with default settings for commit message generation. - Enhanced the commit message generation logic to utilize the effective system prompt based on user settings. --- .../prompts/prompt-customization-section.tsx | 36 ++++++++++++++++++- libs/prompts/src/defaults.ts | 36 +++++++++++++++++++ libs/prompts/src/index.ts | 4 +++ libs/prompts/src/merge.ts | 16 +++++++++ libs/types/src/index.ts | 2 ++ libs/types/src/prompts.ts | 18 ++++++++++ 6 files changed, 111 insertions(+), 1 deletion(-) diff --git a/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx b/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx index eeb11fd3..113328c1 100644 --- a/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx +++ b/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx @@ -12,6 +12,7 @@ import { RotateCcw, Info, AlertTriangle, + GitCommitHorizontal, } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { PromptCustomization, CustomPrompt } from '@automaker/types'; @@ -20,6 +21,7 @@ import { DEFAULT_AGENT_PROMPTS, DEFAULT_BACKLOG_PLAN_PROMPTS, DEFAULT_ENHANCEMENT_PROMPTS, + DEFAULT_COMMIT_MESSAGE_PROMPTS, } from '@automaker/prompts'; interface PromptCustomizationSectionProps { @@ -219,7 +221,7 @@ export function PromptCustomizationSection({ {/* Tabs */}
- + Auto Mode @@ -236,6 +238,10 @@ export function PromptCustomizationSection({ Enhancement + + + Commit + {/* Auto Mode Tab */} @@ -443,6 +449,34 @@ export function PromptCustomizationSection({ />
+ + {/* Commit Message Tab */} + +
+

Commit Message Prompts

+ +
+ +
+ + updatePrompt('commitMessage', 'systemPrompt', value) + } + /> +
+
diff --git a/libs/prompts/src/defaults.ts b/libs/prompts/src/defaults.ts index 20da485a..dfa2ee15 100644 --- a/libs/prompts/src/defaults.ts +++ b/libs/prompts/src/defaults.ts @@ -15,6 +15,7 @@ import type { ResolvedAgentPrompts, ResolvedBacklogPlanPrompts, ResolvedEnhancementPrompts, + ResolvedCommitMessagePrompts, } from '@automaker/types'; import { STATIC_PORT, SERVER_PORT } from '@automaker/types'; @@ -429,6 +430,40 @@ export const DEFAULT_ENHANCEMENT_PROMPTS: ResolvedEnhancementPrompts = { uxReviewerSystemPrompt: UX_REVIEWER_SYSTEM_PROMPT, }; +/** + * ======================================================================== + * COMMIT MESSAGE PROMPTS + * ======================================================================== + */ + +export const DEFAULT_COMMIT_MESSAGE_SYSTEM_PROMPT = `You are a git commit message generator. Your task is to create a clear, concise commit message based on the git diff provided. + +Rules: +- Output ONLY the commit message, nothing else +- First line should be a short summary (50 chars or less) in imperative mood +- Start with a conventional commit type if appropriate (feat:, fix:, refactor:, docs:, chore:, style:, test:, perf:, ci:, build:) +- Keep it concise and descriptive +- Focus on WHAT changed and WHY (if clear from the diff), not HOW +- No quotes, backticks, or extra formatting +- If there are multiple changes, provide a brief summary on the first line + +Examples: +- feat: Add dark mode toggle to settings +- fix: Resolve login validation edge case +- refactor: Extract user authentication logic +- docs: Update installation instructions +- chore: Update dependencies to latest versions +- style: Fix inconsistent indentation in components +- test: Add unit tests for user service +- perf: Optimize database query for user lookup`; + +/** + * Default Commit Message prompts (for AI commit message generation) + */ +export const DEFAULT_COMMIT_MESSAGE_PROMPTS: ResolvedCommitMessagePrompts = { + systemPrompt: DEFAULT_COMMIT_MESSAGE_SYSTEM_PROMPT, +}; + /** * ======================================================================== * COMBINED DEFAULTS @@ -443,4 +478,5 @@ export const DEFAULT_PROMPTS = { agent: DEFAULT_AGENT_PROMPTS, backlogPlan: DEFAULT_BACKLOG_PLAN_PROMPTS, enhancement: DEFAULT_ENHANCEMENT_PROMPTS, + commitMessage: DEFAULT_COMMIT_MESSAGE_PROMPTS, } as const; diff --git a/libs/prompts/src/index.ts b/libs/prompts/src/index.ts index 3fe5fc03..4eae4347 100644 --- a/libs/prompts/src/index.ts +++ b/libs/prompts/src/index.ts @@ -41,6 +41,8 @@ export { DEFAULT_BACKLOG_PLAN_USER_PROMPT_TEMPLATE, DEFAULT_BACKLOG_PLAN_PROMPTS, DEFAULT_ENHANCEMENT_PROMPTS, + DEFAULT_COMMIT_MESSAGE_SYSTEM_PROMPT, + DEFAULT_COMMIT_MESSAGE_PROMPTS, DEFAULT_PROMPTS, } from './defaults.js'; @@ -50,6 +52,7 @@ export { mergeAgentPrompts, mergeBacklogPlanPrompts, mergeEnhancementPrompts, + mergeCommitMessagePrompts, mergeAllPrompts, } from './merge.js'; @@ -59,4 +62,5 @@ export type { ResolvedAgentPrompts, ResolvedBacklogPlanPrompts, ResolvedEnhancementPrompts, + ResolvedCommitMessagePrompts, } from '@automaker/types'; diff --git a/libs/prompts/src/merge.ts b/libs/prompts/src/merge.ts index 2f127fb5..d0d603bd 100644 --- a/libs/prompts/src/merge.ts +++ b/libs/prompts/src/merge.ts @@ -14,17 +14,20 @@ import type { AgentPrompts, BacklogPlanPrompts, EnhancementPrompts, + CommitMessagePrompts, CustomPrompt, ResolvedAutoModePrompts, ResolvedAgentPrompts, ResolvedBacklogPlanPrompts, ResolvedEnhancementPrompts, + ResolvedCommitMessagePrompts, } from '@automaker/types'; import { DEFAULT_AUTO_MODE_PROMPTS, DEFAULT_AGENT_PROMPTS, DEFAULT_BACKLOG_PLAN_PROMPTS, DEFAULT_ENHANCEMENT_PROMPTS, + DEFAULT_COMMIT_MESSAGE_PROMPTS, } from './defaults.js'; /** @@ -120,6 +123,18 @@ export function mergeEnhancementPrompts(custom?: EnhancementPrompts): ResolvedEn }; } +/** + * Merge custom Commit Message prompts with defaults + * Custom prompts override defaults only when enabled=true + */ +export function mergeCommitMessagePrompts( + custom?: CommitMessagePrompts +): ResolvedCommitMessagePrompts { + return { + systemPrompt: resolvePrompt(custom?.systemPrompt, DEFAULT_COMMIT_MESSAGE_PROMPTS.systemPrompt), + }; +} + /** * Merge all custom prompts with defaults * Returns a complete PromptCustomization with all fields populated @@ -130,5 +145,6 @@ export function mergeAllPrompts(custom?: PromptCustomization) { agent: mergeAgentPrompts(custom?.agent), backlogPlan: mergeBacklogPlanPrompts(custom?.backlogPlan), enhancement: mergeEnhancementPrompts(custom?.enhancement), + commitMessage: mergeCommitMessagePrompts(custom?.commitMessage), }; } diff --git a/libs/types/src/index.ts b/libs/types/src/index.ts index 621e5365..72947d7d 100644 --- a/libs/types/src/index.ts +++ b/libs/types/src/index.ts @@ -98,11 +98,13 @@ export type { AgentPrompts, BacklogPlanPrompts, EnhancementPrompts, + CommitMessagePrompts, PromptCustomization, ResolvedAutoModePrompts, ResolvedAgentPrompts, ResolvedBacklogPlanPrompts, ResolvedEnhancementPrompts, + ResolvedCommitMessagePrompts, } from './prompts.js'; export { DEFAULT_PROMPT_CUSTOMIZATION } from './prompts.js'; diff --git a/libs/types/src/prompts.ts b/libs/types/src/prompts.ts index 6f48905f..2e5282a3 100644 --- a/libs/types/src/prompts.ts +++ b/libs/types/src/prompts.ts @@ -94,6 +94,16 @@ export interface EnhancementPrompts { uxReviewerSystemPrompt?: CustomPrompt; } +/** + * CommitMessagePrompts - Customizable prompts for AI commit message generation + * + * Controls how the AI generates git commit messages from diffs. + */ +export interface CommitMessagePrompts { + /** System prompt for generating commit messages */ + systemPrompt?: CustomPrompt; +} + /** * PromptCustomization - Complete set of customizable prompts * @@ -112,6 +122,9 @@ export interface PromptCustomization { /** Enhancement prompts (feature description improvement) */ enhancement?: EnhancementPrompts; + + /** Commit message prompts (AI-generated commit messages) */ + commitMessage?: CommitMessagePrompts; } /** @@ -122,6 +135,7 @@ export const DEFAULT_PROMPT_CUSTOMIZATION: PromptCustomization = { agent: {}, backlogPlan: {}, enhancement: {}, + commitMessage: {}, }; /** @@ -155,3 +169,7 @@ export interface ResolvedEnhancementPrompts { acceptanceSystemPrompt: string; uxReviewerSystemPrompt: string; } + +export interface ResolvedCommitMessagePrompts { + systemPrompt: string; +}