Add Windsurf in edit tool to modify changes, if installed (#853)

This commit is contained in:
Eddie Santos
2025-06-09 16:01:06 -07:00
committed by GitHub
parent 5c9e526f0e
commit 6484dc9008
6 changed files with 92 additions and 15 deletions

View File

@@ -25,6 +25,7 @@ import { ensureCorrectEdit } from '../utils/editCorrector.js';
import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js';
import { openDiff } from '../utils/editor.js';
import { ReadFileTool } from './read-file.js';
import { EditorType } from '../utils/editor.js';
/**
* Parameters for the Edit tool
@@ -467,6 +468,19 @@ Expectation for required parameters:
}
}
async getEditor(outcome: ToolConfirmationOutcome): Promise<EditorType> {
switch (outcome) {
case ToolConfirmationOutcome.ModifyVSCode:
return 'vscode';
case ToolConfirmationOutcome.ModifyWindsurf:
return 'windsurf';
case ToolConfirmationOutcome.ModifyCursor:
return 'cursor';
default:
return 'vim';
}
}
/**
* Creates temp files for the current and proposed file contents and opens a diff tool.
* When the diff tool is closed, the tool will check if the file has been modified and provide the updated params.
@@ -483,11 +497,9 @@ Expectation for required parameters:
this.tempOldDiffPath = oldPath;
this.tempNewDiffPath = newPath;
await openDiff(
this.tempOldDiffPath,
this.tempNewDiffPath,
outcome === ToolConfirmationOutcome.ModifyVSCode ? 'vscode' : 'vim',
);
const editor = await this.getEditor(outcome);
await openDiff(this.tempOldDiffPath, this.tempNewDiffPath, editor);
return await this.getUpdatedParamsIfModified(params, _abortSignal);
}

View File

@@ -233,6 +233,8 @@ export enum ToolConfirmationOutcome {
ProceedAlwaysServer = 'proceed_always_server',
ProceedAlwaysTool = 'proceed_always_tool',
ModifyVSCode = 'modify_vscode',
ModifyWindsurf = 'modify_windsurf',
ModifyCursor = 'modify_cursor',
ModifyVim = 'modify_vim',
Cancel = 'cancel',
}