(mode: string, promptComponent?: PromptComponent, customModes?: ModeConfig[])
| 109 | * If neither is found, the default mode is used. |
| 110 | */ |
| 111 | export function getModeSelection(mode: string, promptComponent?: PromptComponent, customModes?: ModeConfig[]) { |
| 112 | const customMode = findModeBySlug(mode, customModes) |
| 113 | const builtInMode = findModeBySlug(mode, modes) |
| 114 | |
| 115 | // If we have a custom mode, use it entirely |
| 116 | if (customMode) { |
| 117 | return { |
| 118 | roleDefinition: customMode.roleDefinition || "", |
| 119 | baseInstructions: customMode.customInstructions || "", |
| 120 | description: customMode.description || "", |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // Otherwise, use built-in mode as base and merge with promptComponent |
| 125 | const baseMode = builtInMode || modes[0] // fallback to default mode |
| 126 | |
| 127 | return { |
| 128 | roleDefinition: promptComponent?.roleDefinition || baseMode.roleDefinition || "", |
| 129 | baseInstructions: promptComponent?.customInstructions || baseMode.customInstructions || "", |
| 130 | description: baseMode.description || "", |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // Custom error class for file restrictions |
| 135 | export class FileRestrictionError extends Error { |
no test coverage detected