(
modeSlug: string,
customModes?: ModeConfig[],
customModePrompts?: CustomModePrompts,
options?: {
cwd?: string
globalCustomInstructions?: string
language?: string
},
)
| 174 | |
| 175 | // Helper function to get complete mode details with all overrides |
| 176 | export async function getFullModeDetails( |
| 177 | modeSlug: string, |
| 178 | customModes?: ModeConfig[], |
| 179 | customModePrompts?: CustomModePrompts, |
| 180 | options?: { |
| 181 | cwd?: string |
| 182 | globalCustomInstructions?: string |
| 183 | language?: string |
| 184 | }, |
| 185 | ): Promise<ModeConfig> { |
| 186 | // First get the base mode config from custom modes or built-in modes |
| 187 | const baseMode = getModeBySlug(modeSlug, customModes) || modes.find((m) => m.slug === modeSlug) || modes[0] |
| 188 | |
| 189 | // Check for any prompt component overrides |
| 190 | const promptComponent = customModePrompts?.[modeSlug] |
| 191 | |
| 192 | // Get the base custom instructions |
| 193 | const baseCustomInstructions = promptComponent?.customInstructions || baseMode.customInstructions || "" |
| 194 | const baseWhenToUse = promptComponent?.whenToUse || baseMode.whenToUse || "" |
| 195 | const baseDescription = promptComponent?.description || baseMode.description || "" |
| 196 | |
| 197 | // If we have cwd, load and combine all custom instructions |
| 198 | let fullCustomInstructions = baseCustomInstructions |
| 199 | if (options?.cwd) { |
| 200 | fullCustomInstructions = await addCustomInstructions( |
| 201 | baseCustomInstructions, |
| 202 | options.globalCustomInstructions || "", |
| 203 | options.cwd, |
| 204 | modeSlug, |
| 205 | { language: options.language }, |
| 206 | ) |
| 207 | } |
| 208 | |
| 209 | // Return mode with any overrides applied |
| 210 | return { |
| 211 | ...baseMode, |
| 212 | roleDefinition: promptComponent?.roleDefinition || baseMode.roleDefinition, |
| 213 | whenToUse: baseWhenToUse, |
| 214 | description: baseDescription, |
| 215 | customInstructions: fullCustomInstructions, |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // Helper function to safely get role definition |
| 220 | export function getRoleDefinition(modeSlug: string, customModes?: ModeConfig[]): string { |
no test coverage detected