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.
This commit is contained in:
Shirone
2026-01-12 20:48:08 +01:00
parent 5e4f5f86cd
commit 0261ec2892
6 changed files with 111 additions and 1 deletions

View File

@@ -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 */}
<div className="p-6">
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList className="grid grid-cols-4 w-full">
<TabsList className="grid grid-cols-5 w-full">
<TabsTrigger value="auto-mode" className="gap-2">
<Bot className="w-4 h-4" />
Auto Mode
@@ -236,6 +238,10 @@ export function PromptCustomizationSection({
<Sparkles className="w-4 h-4" />
Enhancement
</TabsTrigger>
<TabsTrigger value="commit-message" className="gap-2">
<GitCommitHorizontal className="w-4 h-4" />
Commit
</TabsTrigger>
</TabsList>
{/* Auto Mode Tab */}
@@ -443,6 +449,34 @@ export function PromptCustomizationSection({
/>
</div>
</TabsContent>
{/* Commit Message Tab */}
<TabsContent value="commit-message" className="space-y-6 mt-6">
<div className="flex items-center justify-between mb-4">
<h3 className="text-sm font-medium text-foreground">Commit Message Prompts</h3>
<Button
variant="ghost"
size="sm"
onClick={() => resetToDefaults('commitMessage')}
className="gap-2"
>
<RotateCcw className="w-3 h-3" />
Reset Section
</Button>
</div>
<div className="space-y-4">
<PromptField
label="System Prompt"
description="Instructions for generating git commit messages from diffs. The AI will receive the git diff and generate a conventional commit message."
defaultValue={DEFAULT_COMMIT_MESSAGE_PROMPTS.systemPrompt}
customValue={promptCustomization?.commitMessage?.systemPrompt}
onCustomValueChange={(value) =>
updatePrompt('commitMessage', 'systemPrompt', value)
}
/>
</div>
</TabsContent>
</Tabs>
</div>
</div>

View File

@@ -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;

View File

@@ -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';

View File

@@ -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),
};
}

View File

@@ -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';

View File

@@ -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;
}