Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/core/diff/strategies/multi-search-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class MultiSearchReplaceDiffStrategy implements DiffStrategy {
private fuzzyThreshold: number
private bufferLines: number

getName(): string {
return "MultiSearchReplace"
}

constructor(fuzzyThreshold?: number, bufferLines?: number) {
// Use provided threshold or default to exact matching (1.0)
// Note: fuzzyThreshold is inverted in UI (0% = 1.0, 10% = 0.9)
Expand Down
4 changes: 4 additions & 0 deletions src/core/diff/strategies/new-unified/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { DiffResult, DiffStrategy } from "../../types"
export class NewUnifiedDiffStrategy implements DiffStrategy {
private readonly confidenceThreshold: number

getName(): string {
return "NewUnified"
}

constructor(confidenceThreshold: number = 1) {
this.confidenceThreshold = Math.max(confidenceThreshold, 0.8)
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/diff/strategies/search-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class SearchReplaceDiffStrategy implements DiffStrategy {
private fuzzyThreshold: number
private bufferLines: number

getName(): string {
return "SearchReplace"
}

constructor(fuzzyThreshold?: number, bufferLines?: number) {
// Use provided threshold or default to exact matching (1.0)
// Note: fuzzyThreshold is inverted in UI (0% = 1.0, 10% = 0.9)
Expand Down
3 changes: 3 additions & 0 deletions src/core/diff/strategies/unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { applyPatch } from "diff"
import { DiffStrategy, DiffResult } from "../types"

export class UnifiedDiffStrategy implements DiffStrategy {
getName(): string {
return "Unified"
}
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
return `## apply_diff
Description: Apply a unified diff to a file at the specified path. This tool is useful when you need to make specific modifications to a file based on a set of changes provided in unified diff format (diff -U3).
Expand Down
7 changes: 6 additions & 1 deletion src/core/diff/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ export type DiffResult =
}
failParts?: DiffResult[]
} & ({ error: string } | { failParts: DiffResult[] }))

export interface DiffStrategy {
/**
* Get the name of this diff strategy for analytics and debugging
* @returns The name of the diff strategy
*/
getName(): string

/**
* Get the tool description for this diff strategy
* @param args The tool arguments including cwd and toolOptions
Expand Down
1 change: 1 addition & 0 deletions src/core/prompts/__tests__/sections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe("getCapabilitiesSection", () => {
const cwd = "/test/path"
const mcpHub = undefined
const mockDiffStrategy: DiffStrategy = {
getName: () => "MockStrategy",
getToolDescription: () => "apply_diff tool description",
applyDiff: async (originalContent: string, diffContent: string): Promise<DiffResult> => {
return { success: true, content: "mock result" }
Expand Down
4 changes: 4 additions & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
}

if (currentCline?.diffStrategy) {
properties.diffStrategy = currentCline.diffStrategy.getName()
}

return properties
}
}