Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ export const globalSettingsSchema = z.object({
alwaysAllowWriteOutsideWorkspace: z.boolean().optional(),
alwaysAllowWriteProtected: z.boolean().optional(),
writeDelayMs: z.number().min(0).optional(),
/**
* Fuzzy match threshold for diff operations.
* Controls how strictly the search content must match the original file content.
* Value between 0 and 1 where:
* - 1.0 (100%) = exact match required (default)
* - 0.9 (90%) = allows minor differences (recommended for some models)
* - 0.8 (80%) = more lenient matching
* Lower values allow more flexibility but may increase false positives.
* @default 1.0
*/
fuzzyMatchThreshold: z.number().min(0).max(1).optional(),
alwaysAllowBrowser: z.boolean().optional(),
requestDelaySeconds: z.number().optional(),
alwaysAllowMcp: z.boolean().optional(),
Expand Down
12 changes: 10 additions & 2 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ export interface TaskOptions extends CreateTaskOptions {
workspacePath?: string
/** Initial status for the task's history item (e.g., "active" for child tasks) */
initialStatus?: "active" | "delegated" | "completed"
/**
* Fuzzy match threshold for diff operations (0-1).
* 1.0 = exact match required (default)
* 0.9 = 90% similarity (recommended for some models)
* @default 1.0
*/
fuzzyMatchThreshold?: number
}

export class Task extends EventEmitter<TaskEvents> implements TaskLike {
Expand Down Expand Up @@ -565,6 +572,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
initialTodos,
workspacePath,
initialStatus,
fuzzyMatchThreshold,
}: TaskOptions) {
super()

Expand Down Expand Up @@ -683,8 +691,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// Listen for provider profile changes to update parser state
this.setupProviderProfileChangeListener(provider)

// Set up diff strategy
this.diffStrategy = new MultiSearchReplaceDiffStrategy()
// Set up diff strategy with optional fuzzy match threshold
this.diffStrategy = new MultiSearchReplaceDiffStrategy(fuzzyMatchThreshold)

this.toolRepetitionDetector = new ToolRepetitionDetector(this.consecutiveMistakeLimit)

Expand Down
14 changes: 12 additions & 2 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,15 @@ export class ClineProvider
}
}

const { apiConfiguration, enableCheckpoints, checkpointTimeout, experiments, cloudUserInfo, taskSyncEnabled } =
await this.getState()
const {
apiConfiguration,
enableCheckpoints,
checkpointTimeout,
experiments,
cloudUserInfo,
taskSyncEnabled,
fuzzyMatchThreshold,
} = await this.getState()

const task = new Task({
provider: this,
Expand All @@ -980,6 +987,7 @@ export class ClineProvider
consecutiveMistakeLimit: apiConfiguration.consecutiveMistakeLimit,
historyItem,
experiments,
fuzzyMatchThreshold,
rootTask: historyItem.rootTask,
parentTask: historyItem.parentTask,
taskNumber: historyItem.number,
Expand Down Expand Up @@ -2877,6 +2885,7 @@ export class ClineProvider
experiments,
cloudUserInfo,
remoteControlEnabled,
fuzzyMatchThreshold,
} = await this.getState()

// Single-open-task invariant: always enforce for user-initiated top-level tasks
Expand All @@ -2901,6 +2910,7 @@ export class ClineProvider
task: text,
images,
experiments,
fuzzyMatchThreshold,
rootTask: this.clineStack.length > 0 ? this.clineStack[0] : undefined,
parentTask,
taskNumber: this.clineStack.length + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
includeDiagnosticMessages?: boolean
maxDiagnosticMessages?: number
writeDelayMs: number
fuzzyMatchThreshold?: number
includeCurrentTime?: boolean
includeCurrentCost?: boolean
maxGitStatusFiles?: number
Expand All @@ -57,6 +58,7 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
| "includeDiagnosticMessages"
| "maxDiagnosticMessages"
| "writeDelayMs"
| "fuzzyMatchThreshold"
| "includeCurrentTime"
| "includeCurrentCost"
| "maxGitStatusFiles"
Expand All @@ -78,6 +80,7 @@ export const ContextManagementSettings = ({
includeDiagnosticMessages,
maxDiagnosticMessages,
writeDelayMs,
fuzzyMatchThreshold,
includeCurrentTime,
includeCurrentCost,
maxGitStatusFiles,
Expand Down Expand Up @@ -406,6 +409,29 @@ export const ContextManagementSettings = ({
</div>
</SearchableSetting>

<SearchableSetting
settingId="context-fuzzy-match-threshold"
section="contextManagement"
label={t("settings:contextManagement.fuzzyMatchThreshold.label")}>
<span className="block font-medium mb-1">
{t("settings:contextManagement.fuzzyMatchThreshold.label")}
</span>
<div className="flex items-center gap-2">
<Slider
min={80}
max={100}
step={1}
value={[Math.round((fuzzyMatchThreshold ?? 1.0) * 100)]}
onValueChange={([value]) => setCachedStateField("fuzzyMatchThreshold", value / 100)}
data-testid="fuzzy-match-threshold-slider"
/>
<span className="w-12">{Math.round((fuzzyMatchThreshold ?? 1.0) * 100)}%</span>
</div>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.fuzzyMatchThreshold.description")}
</div>
</SearchableSetting>

<SearchableSetting
settingId="context-include-current-time"
section="contextManagement"
Expand Down
2 changes: 2 additions & 0 deletions webview-ui/src/components/settings/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
terminalZshP10k,
terminalZdotdir,
writeDelayMs,
fuzzyMatchThreshold,
showRooIgnoredFiles,
enableSubfolderRules,
remoteBrowserEnabled,
Expand Down Expand Up @@ -857,6 +858,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
includeDiagnosticMessages={includeDiagnosticMessages}
maxDiagnosticMessages={maxDiagnosticMessages}
writeDelayMs={writeDelayMs}
fuzzyMatchThreshold={fuzzyMatchThreshold}
includeCurrentTime={includeCurrentTime}
includeCurrentCost={includeCurrentCost}
maxGitStatusFiles={maxGitStatusFiles}
Expand Down
4 changes: 4 additions & 0 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,10 @@
"description": "Time to wait after file writes before proceeding, allowing diagnostic tools to process changes and detect issues."
}
},
"fuzzyMatchThreshold": {
"label": "Fuzzy match threshold for file edits",
"description": "Controls how strictly the search content must match when editing files. Lower values allow more tolerance for minor formatting differences that some models produce. 100% requires exact match (default), 90% is recommended for models that produce slight variations."
},
"condensingThreshold": {
"label": "Condensing Trigger Threshold",
"selectProfile": "Configure threshold for profile",
Expand Down
Loading