feat: introduce experimental diff strategy toggle and enhance diff handling

- Added support for an experimental diff strategy in the Cline class, allowing users to opt for a new unified diff approach.
- Updated the getDiffStrategy function to accommodate the experimental strategy, adjusting the fuzzy match threshold accordingly.
- Integrated experimentalDiffStrategy into the global state management, enabling persistence across sessions.
- Enhanced the ClineProvider and related components to handle the new experimental strategy, including UI updates for user settings.
- Improved task history management to include the experimentalDiffStrategy setting, ensuring consistency in task execution.
- Updated relevant interfaces and types to reflect the new experimentalDiffStrategy property.
This commit is contained in:
Daniel Riccio
2025-01-14 17:57:09 -05:00
parent a211927097
commit f6e85fa133
8 changed files with 89 additions and 27 deletions

View File

@@ -7,10 +7,14 @@ import { NewUnifiedDiffStrategy } from './strategies/new-unified'
* @param model The name of the model being used (e.g., 'gpt-4', 'claude-3-opus')
* @returns The appropriate diff strategy for the model
*/
export function getDiffStrategy(model: string, fuzzyMatchThreshold?: number): DiffStrategy {
// For now, return SearchReplaceDiffStrategy for all models
// This architecture allows for future optimizations based on model capabilities
return new NewUnifiedDiffStrategy()
export function getDiffStrategy(model: string, fuzzyMatchThreshold?: number, experimentalDiffStrategy?: boolean): DiffStrategy {
if (experimentalDiffStrategy) {
// Use the fuzzyMatchThreshold with a minimum of 0.8 (80%)
const threshold = Math.max(fuzzyMatchThreshold ?? 1.0, 0.8)
return new NewUnifiedDiffStrategy(threshold)
}
// Default to the stable SearchReplaceDiffStrategy
return new SearchReplaceDiffStrategy()
}
export type { DiffStrategy }