ideDiffConfig.ts
1 import type { ToolInput } from './useFilePermissionDialog.js' 2 3 export interface FileEdit { 4 old_string: string 5 new_string: string 6 replace_all?: boolean 7 } 8 9 export interface IDEDiffConfig { 10 filePath: string 11 edits?: FileEdit[] 12 editMode?: 'single' | 'multiple' 13 } 14 15 export interface IDEDiffChangeInput { 16 file_path: string 17 edits: FileEdit[] 18 } 19 20 export interface IDEDiffSupport<TInput extends ToolInput> { 21 getConfig(input: TInput): IDEDiffConfig 22 applyChanges(input: TInput, modifiedEdits: FileEdit[]): TInput 23 } 24 25 export function createSingleEditDiffConfig( 26 filePath: string, 27 oldString: string, 28 newString: string, 29 replaceAll?: boolean, 30 ): IDEDiffConfig { 31 return { 32 filePath, 33 edits: [ 34 { 35 old_string: oldString, 36 new_string: newString, 37 replace_all: replaceAll, 38 }, 39 ], 40 editMode: 'single', 41 } 42 }