mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Add Windsurf in edit tool to modify changes, if installed (#853)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user