Only allow usage of diff tool if enabled in settings

This commit is contained in:
Matt Rubens
2025-01-21 16:10:51 -05:00
parent 269ada48f2
commit b8e2dac2b9
14 changed files with 850 additions and 40 deletions

View File

@@ -103,12 +103,24 @@ export function isCustomMode(slug: string, customModes?: ModeConfig[]): boolean
return !!customModes?.some((mode) => mode.slug === slug)
}
export function isToolAllowedForMode(tool: string, modeSlug: string, customModes: ModeConfig[]): boolean {
export function isToolAllowedForMode(
tool: string,
modeSlug: string,
customModes: ModeConfig[],
toolRequirements?: Record<string, boolean>,
): boolean {
// Always allow these tools
if (ALWAYS_AVAILABLE_TOOLS.includes(tool as any)) {
return true
}
// Check tool requirements if any exist
if (toolRequirements && tool in toolRequirements) {
if (!toolRequirements[tool]) {
return false
}
}
const mode = getModeBySlug(modeSlug, customModes)
if (!mode) {
return false