diff --git a/src/core/diff/strategies/multi-search-replace.ts b/src/core/diff/strategies/multi-search-replace.ts index bcf2f654308..ad12448d046 100644 --- a/src/core/diff/strategies/multi-search-replace.ts +++ b/src/core/diff/strategies/multi-search-replace.ts @@ -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) diff --git a/src/core/diff/strategies/new-unified/index.ts b/src/core/diff/strategies/new-unified/index.ts index d82a05a1045..5b385616f6f 100644 --- a/src/core/diff/strategies/new-unified/index.ts +++ b/src/core/diff/strategies/new-unified/index.ts @@ -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) } diff --git a/src/core/diff/strategies/search-replace.ts b/src/core/diff/strategies/search-replace.ts index a9bf46758de..0f1ad1d1e8b 100644 --- a/src/core/diff/strategies/search-replace.ts +++ b/src/core/diff/strategies/search-replace.ts @@ -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) diff --git a/src/core/diff/strategies/unified.ts b/src/core/diff/strategies/unified.ts index f1cdb3b5849..f4d6ead6aab 100644 --- a/src/core/diff/strategies/unified.ts +++ b/src/core/diff/strategies/unified.ts @@ -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). diff --git a/src/core/diff/types.ts b/src/core/diff/types.ts index e12a47762d5..68097710fb6 100644 --- a/src/core/diff/types.ts +++ b/src/core/diff/types.ts @@ -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 diff --git a/src/core/prompts/__tests__/sections.test.ts b/src/core/prompts/__tests__/sections.test.ts index 630da9064ba..2716f610f49 100644 --- a/src/core/prompts/__tests__/sections.test.ts +++ b/src/core/prompts/__tests__/sections.test.ts @@ -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 => { return { success: true, content: "mock result" } diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 70b21f87bb4..d0362cf8d76 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -2704,6 +2704,10 @@ export class ClineProvider implements vscode.WebviewViewProvider { } } + if (currentCline?.diffStrategy) { + properties.diffStrategy = currentCline.diffStrategy.getName() + } + return properties } }