Merge pull request #1599 from RooVetGit/diff_strategy_telemetry

Add diffStrategy name to telemetry
This commit is contained in:
Matt Rubens 2025-03-12 13:54:28 -04:00 committed by GitHub
commit 3cd6c7416a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 26 additions and 1 deletions

View file

@ -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)

View file

@ -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)
}

View file

@ -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)

View file

@ -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).

View file

@ -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

View file

@ -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" }

View file

@ -2704,6 +2704,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
}
if (currentCline?.diffStrategy) {
properties.diffStrategy = currentCline.diffStrategy.getName()
}
return properties
}
}