mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-31 12:49:41 +01:00
3de6af5556
After talking to Kai, we decided that the rare case of sensitive files edits should just use our standard confirmation UI instead of adding more variances to the base chat experience.
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import type * as vscode from 'vscode';
|
|
import { URI } from '../../../util/vs/base/common/uri';
|
|
import { ToolName } from '../common/toolNames';
|
|
import { ToolRegistry } from '../common/toolsRegistry';
|
|
import { AbstractReplaceStringTool } from './abstractReplaceStringTool';
|
|
import { resolveToolInputPath } from './toolUtils';
|
|
|
|
export interface IReplaceStringToolParams {
|
|
explanation: string;
|
|
filePath: string;
|
|
oldString: string;
|
|
newString: string;
|
|
}
|
|
|
|
export class ReplaceStringTool extends AbstractReplaceStringTool<IReplaceStringToolParams> {
|
|
public static toolName = ToolName.ReplaceString;
|
|
|
|
protected override urisForInput(input: IReplaceStringToolParams): readonly URI[] {
|
|
return [resolveToolInputPath(input.filePath, this.promptPathRepresentationService)];
|
|
}
|
|
|
|
async invoke(options: vscode.LanguageModelToolInvocationOptions<IReplaceStringToolParams>, token: vscode.CancellationToken) {
|
|
const prepared = await this.prepareEditsForFile(options, options.input, token);
|
|
return this.applyAllEdits(options, [prepared], token);
|
|
}
|
|
|
|
protected override toolName(): ToolName {
|
|
return ReplaceStringTool.toolName;
|
|
}
|
|
}
|
|
|
|
ToolRegistry.registerTool(ReplaceStringTool);
|