refactor: separate mode and support prompts

- Rename customPrompts to customModePrompts for mode-specific prompts
- Add new customSupportPrompts type for support action prompts
- Update types to be more specific (CustomModePrompts and CustomSupportPrompts)
- Fix all related tests and component implementations
This commit is contained in:
sam hoang
2025-01-24 01:46:33 +07:00
parent 085d42873c
commit f86e96d157
13 changed files with 119 additions and 99 deletions

View File

@@ -84,11 +84,11 @@ type SupportPromptType = keyof typeof defaultTemplates
export const supportPrompt = {
default: defaultTemplates,
get: (customPrompts: Record<string, any> | undefined, type: SupportPromptType): string => {
return customPrompts?.[type] ?? defaultTemplates[type]
get: (customSupportPrompts: Record<string, any> | undefined, type: SupportPromptType): string => {
return customSupportPrompts?.[type] ?? defaultTemplates[type]
},
create: (type: SupportPromptType, params: PromptParams, customPrompts?: Record<string, any>): string => {
const template = supportPrompt.get(customPrompts, type)
create: (type: SupportPromptType, params: PromptParams, customSupportPrompts?: Record<string, any>): string => {
const template = supportPrompt.get(customSupportPrompts, type)
return createPrompt(template, params)
},
} as const
@@ -102,3 +102,7 @@ export const supportPromptLabels: Record<SupportPromptType, string> = {
IMPROVE: "Improve Code",
ENHANCE: "Enhance Prompt",
} as const
export type CustomSupportPrompts = {
[key: string]: string | undefined
}