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

@@ -38,13 +38,17 @@ async function generatePrompt(
customModeConfigs?: ModeConfig[],
globalCustomInstructions?: string,
preferredLanguage?: string,
diffEnabled?: boolean,
): Promise<string> {
if (!context) {
throw new Error("Extension context is required for generating system prompt")
}
// If diff is disabled, don't pass the diffStrategy
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
const [mcpServersSection, modesSection] = await Promise.all([
getMcpServersSection(mcpHub, diffStrategy),
getMcpServersSection(mcpHub, effectiveDiffStrategy),
getModesSection(context),
])
@@ -60,7 +64,7 @@ ${getToolDescriptionsForMode(
mode,
cwd,
supportsComputerUse,
diffStrategy,
effectiveDiffStrategy,
browserViewportSize,
mcpHub,
customModeConfigs,
@@ -70,7 +74,7 @@ ${getToolUseGuidelinesSection()}
${mcpServersSection}
${getCapabilitiesSection(cwd, supportsComputerUse, mcpHub, diffStrategy)}
${getCapabilitiesSection(cwd, supportsComputerUse, mcpHub, effectiveDiffStrategy)}
${modesSection}
@@ -80,7 +84,7 @@ ${getSystemInfoSection(cwd, mode, customModeConfigs)}
${getObjectiveSection()}
${await addCustomInstructions(modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { preferredLanguage })}`
${await addCustomInstructions(promptComponent?.customInstructions || modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { preferredLanguage })}`
return basePrompt
}
@@ -97,6 +101,7 @@ export const SYSTEM_PROMPT = async (
customModes?: ModeConfig[],
globalCustomInstructions?: string,
preferredLanguage?: string,
diffEnabled?: boolean,
): Promise<string> => {
if (!context) {
throw new Error("Extension context is required for generating system prompt")
@@ -114,17 +119,21 @@ export const SYSTEM_PROMPT = async (
// Get full mode config from custom modes or fall back to built-in modes
const currentMode = getModeBySlug(mode, customModes) || modes.find((m) => m.slug === mode) || modes[0]
// If diff is disabled, don't pass the diffStrategy
const effectiveDiffStrategy = diffEnabled ? diffStrategy : undefined
return generatePrompt(
context,
cwd,
supportsComputerUse,
currentMode.slug,
mcpHub,
diffStrategy,
effectiveDiffStrategy,
browserViewportSize,
promptComponent,
customModes,
globalCustomInstructions,
preferredLanguage,
diffEnabled,
)
}