Skip to content

Commit 0d8c6e7

Browse files
committed
Add diffStrategy name to telemetry
1 parent 705b3ba commit 0d8c6e7

File tree

7 files changed

+26
-1
lines changed

7 files changed

+26
-1
lines changed

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export class MultiSearchReplaceDiffStrategy implements DiffStrategy {
3333
private fuzzyThreshold: number
3434
private bufferLines: number
3535

36+
getName(): string {
37+
return "MultiSearchReplace"
38+
}
39+
3640
constructor(fuzzyThreshold?: number, bufferLines?: number) {
3741
// Use provided threshold or default to exact matching (1.0)
3842
// Note: fuzzyThreshold is inverted in UI (0% = 1.0, 10% = 0.9)

src/core/diff/strategies/new-unified/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { DiffResult, DiffStrategy } from "../../types"
66
export class NewUnifiedDiffStrategy implements DiffStrategy {
77
private readonly confidenceThreshold: number
88

9+
getName(): string {
10+
return "NewUnified"
11+
}
12+
913
constructor(confidenceThreshold: number = 1) {
1014
this.confidenceThreshold = Math.max(confidenceThreshold, 0.8)
1115
}

src/core/diff/strategies/search-replace.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export class SearchReplaceDiffStrategy implements DiffStrategy {
3131
private fuzzyThreshold: number
3232
private bufferLines: number
3333

34+
getName(): string {
35+
return "SearchReplace"
36+
}
37+
3438
constructor(fuzzyThreshold?: number, bufferLines?: number) {
3539
// Use provided threshold or default to exact matching (1.0)
3640
// Note: fuzzyThreshold is inverted in UI (0% = 1.0, 10% = 0.9)

src/core/diff/strategies/unified.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { applyPatch } from "diff"
22
import { DiffStrategy, DiffResult } from "../types"
33

44
export class UnifiedDiffStrategy implements DiffStrategy {
5+
getName(): string {
6+
return "Unified"
7+
}
58
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
69
return `## apply_diff
710
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).

src/core/diff/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ export type DiffResult =
1919
}
2020
failParts?: DiffResult[]
2121
} & ({ error: string } | { failParts: DiffResult[] }))
22-
2322
export interface DiffStrategy {
23+
/**
24+
* Get the name of this diff strategy for analytics and debugging
25+
* @returns The name of the diff strategy
26+
*/
27+
getName(): string
28+
2429
/**
2530
* Get the tool description for this diff strategy
2631
* @param args The tool arguments including cwd and toolOptions

src/core/prompts/__tests__/sections.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe("getCapabilitiesSection", () => {
3333
const cwd = "/test/path"
3434
const mcpHub = undefined
3535
const mockDiffStrategy: DiffStrategy = {
36+
getName: () => "MockStrategy",
3637
getToolDescription: () => "apply_diff tool description",
3738
applyDiff: async (originalContent: string, diffContent: string): Promise<DiffResult> => {
3839
return { success: true, content: "mock result" }

src/core/webview/ClineProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
27042704
}
27052705
}
27062706

2707+
if (currentCline?.diffStrategy) {
2708+
properties.diffStrategy = currentCline.diffStrategy.getName()
2709+
}
2710+
27072711
return properties
27082712
}
27092713
}

0 commit comments

Comments
 (0)