mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
Add comprehensive prompt customization system allowing users to customize
all AI prompts (Auto Mode, Agent Runner, Backlog Plan, Enhancement) through
the Settings UI.
## Features
### Core Customization System
- New TypeScript types for prompt customization with enabled flag
- CustomPrompt interface with value and enabled state
- Prompts preserved even when disabled (no data loss)
- Merged prompt system (custom overrides defaults when enabled)
- Persistent storage in ~/.automaker/settings.json
### Settings UI
- New "Prompt Customization" section in Settings
- 4 tabs: Auto Mode, Agent, Backlog Plan, Enhancement
- Toggle-based editing (read-only default → editable custom)
- Dynamic textarea height based on prompt length (120px-600px)
- Visual state indicators (Custom/Default labels)
### Warning System
- Critical prompt warnings for Backlog Plan (JSON format requirement)
- Field-level warnings when editing critical prompts
- Info banners for Auto Mode planning markers
- Color-coded warnings (blue=info, amber=critical)
### Backend Integration
- Auto Mode service loads prompts from settings
- Agent service loads prompts from settings
- Backlog Plan service loads prompts from settings
- Enhancement endpoint loads prompts from settings
- Settings sync includes promptCustomization field
### Files Changed
- libs/types/src/prompts.ts - Type definitions
- libs/prompts/src/defaults.ts - Default prompt values
- libs/prompts/src/merge.ts - Merge utilities
- apps/ui/src/components/views/settings-view/prompts/ - UI components
- apps/server/src/lib/settings-helpers.ts - getPromptCustomization()
- All service files updated to use customizable prompts
## Technical Details
Prompt storage format:
```json
{
"promptCustomization": {
"autoMode": {
"planningLite": {
"value": "Custom prompt text...",
"enabled": true
}
}
}
}
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
131 lines
4.1 KiB
TypeScript
131 lines
4.1 KiB
TypeScript
/**
|
|
* Prompt Merging Utilities
|
|
*
|
|
* Merges user-customized prompts with built-in defaults.
|
|
* Used by services to get effective prompts at runtime.
|
|
*
|
|
* Custom prompts have an `enabled` flag - when true, the custom value is used.
|
|
* When false or undefined, the default is used instead.
|
|
*/
|
|
|
|
import type {
|
|
PromptCustomization,
|
|
AutoModePrompts,
|
|
AgentPrompts,
|
|
BacklogPlanPrompts,
|
|
EnhancementPrompts,
|
|
CustomPrompt,
|
|
ResolvedAutoModePrompts,
|
|
ResolvedAgentPrompts,
|
|
ResolvedBacklogPlanPrompts,
|
|
ResolvedEnhancementPrompts,
|
|
} from '@automaker/types';
|
|
import {
|
|
DEFAULT_AUTO_MODE_PROMPTS,
|
|
DEFAULT_AGENT_PROMPTS,
|
|
DEFAULT_BACKLOG_PLAN_PROMPTS,
|
|
DEFAULT_ENHANCEMENT_PROMPTS,
|
|
} from './defaults.js';
|
|
|
|
/**
|
|
* Resolve a custom prompt to its effective string value
|
|
* Returns the custom value if enabled=true, otherwise returns the default
|
|
*/
|
|
function resolvePrompt(custom: CustomPrompt | undefined, defaultValue: string): string {
|
|
return custom?.enabled ? custom.value : defaultValue;
|
|
}
|
|
|
|
/**
|
|
* Merge custom Auto Mode prompts with defaults
|
|
* Custom prompts override defaults only when enabled=true
|
|
*/
|
|
export function mergeAutoModePrompts(custom?: AutoModePrompts): ResolvedAutoModePrompts {
|
|
return {
|
|
planningLite: resolvePrompt(custom?.planningLite, DEFAULT_AUTO_MODE_PROMPTS.planningLite),
|
|
planningLiteWithApproval: resolvePrompt(
|
|
custom?.planningLiteWithApproval,
|
|
DEFAULT_AUTO_MODE_PROMPTS.planningLiteWithApproval
|
|
),
|
|
planningSpec: resolvePrompt(custom?.planningSpec, DEFAULT_AUTO_MODE_PROMPTS.planningSpec),
|
|
planningFull: resolvePrompt(custom?.planningFull, DEFAULT_AUTO_MODE_PROMPTS.planningFull),
|
|
featurePromptTemplate: resolvePrompt(
|
|
custom?.featurePromptTemplate,
|
|
DEFAULT_AUTO_MODE_PROMPTS.featurePromptTemplate
|
|
),
|
|
followUpPromptTemplate: resolvePrompt(
|
|
custom?.followUpPromptTemplate,
|
|
DEFAULT_AUTO_MODE_PROMPTS.followUpPromptTemplate
|
|
),
|
|
continuationPromptTemplate: resolvePrompt(
|
|
custom?.continuationPromptTemplate,
|
|
DEFAULT_AUTO_MODE_PROMPTS.continuationPromptTemplate
|
|
),
|
|
pipelineStepPromptTemplate: resolvePrompt(
|
|
custom?.pipelineStepPromptTemplate,
|
|
DEFAULT_AUTO_MODE_PROMPTS.pipelineStepPromptTemplate
|
|
),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Merge custom Agent prompts with defaults
|
|
* Custom prompts override defaults only when enabled=true
|
|
*/
|
|
export function mergeAgentPrompts(custom?: AgentPrompts): ResolvedAgentPrompts {
|
|
return {
|
|
systemPrompt: resolvePrompt(custom?.systemPrompt, DEFAULT_AGENT_PROMPTS.systemPrompt),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Merge custom Backlog Plan prompts with defaults
|
|
* Custom prompts override defaults only when enabled=true
|
|
*/
|
|
export function mergeBacklogPlanPrompts(custom?: BacklogPlanPrompts): ResolvedBacklogPlanPrompts {
|
|
return {
|
|
systemPrompt: resolvePrompt(custom?.systemPrompt, DEFAULT_BACKLOG_PLAN_PROMPTS.systemPrompt),
|
|
userPromptTemplate: resolvePrompt(
|
|
custom?.userPromptTemplate,
|
|
DEFAULT_BACKLOG_PLAN_PROMPTS.userPromptTemplate
|
|
),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Merge custom Enhancement prompts with defaults
|
|
* Custom prompts override defaults only when enabled=true
|
|
*/
|
|
export function mergeEnhancementPrompts(custom?: EnhancementPrompts): ResolvedEnhancementPrompts {
|
|
return {
|
|
improveSystemPrompt: resolvePrompt(
|
|
custom?.improveSystemPrompt,
|
|
DEFAULT_ENHANCEMENT_PROMPTS.improveSystemPrompt
|
|
),
|
|
technicalSystemPrompt: resolvePrompt(
|
|
custom?.technicalSystemPrompt,
|
|
DEFAULT_ENHANCEMENT_PROMPTS.technicalSystemPrompt
|
|
),
|
|
simplifySystemPrompt: resolvePrompt(
|
|
custom?.simplifySystemPrompt,
|
|
DEFAULT_ENHANCEMENT_PROMPTS.simplifySystemPrompt
|
|
),
|
|
acceptanceSystemPrompt: resolvePrompt(
|
|
custom?.acceptanceSystemPrompt,
|
|
DEFAULT_ENHANCEMENT_PROMPTS.acceptanceSystemPrompt
|
|
),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Merge all custom prompts with defaults
|
|
* Returns a complete PromptCustomization with all fields populated
|
|
*/
|
|
export function mergeAllPrompts(custom?: PromptCustomization) {
|
|
return {
|
|
autoMode: mergeAutoModePrompts(custom?.autoMode),
|
|
agent: mergeAgentPrompts(custom?.agent),
|
|
backlogPlan: mergeBacklogPlanPrompts(custom?.backlogPlan),
|
|
enhancement: mergeEnhancementPrompts(custom?.enhancement),
|
|
};
|
|
}
|