mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Migrate EditTool, GrepTool, and GlobTool to DeclarativeTool (#5744)
This commit is contained in:
@@ -9,6 +9,7 @@ import { SchemaValidator } from '../utils/schemaValidator.js';
|
||||
import { makeRelative, shortenPath } from '../utils/paths.js';
|
||||
import {
|
||||
BaseDeclarativeTool,
|
||||
BaseToolInvocation,
|
||||
Icon,
|
||||
ToolInvocation,
|
||||
ToolLocation,
|
||||
@@ -45,13 +46,16 @@ export interface ReadFileToolParams {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
class ReadFileToolInvocation
|
||||
implements ToolInvocation<ReadFileToolParams, ToolResult>
|
||||
{
|
||||
class ReadFileToolInvocation extends BaseToolInvocation<
|
||||
ReadFileToolParams,
|
||||
ToolResult
|
||||
> {
|
||||
constructor(
|
||||
private config: Config,
|
||||
public params: ReadFileToolParams,
|
||||
) {}
|
||||
params: ReadFileToolParams,
|
||||
) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
getDescription(): string {
|
||||
const relativePath = makeRelative(
|
||||
@@ -61,14 +65,10 @@ class ReadFileToolInvocation
|
||||
return shortenPath(relativePath);
|
||||
}
|
||||
|
||||
toolLocations(): ToolLocation[] {
|
||||
override toolLocations(): ToolLocation[] {
|
||||
return [{ path: this.params.absolute_path, line: this.params.offset }];
|
||||
}
|
||||
|
||||
shouldConfirmExecute(): Promise<false> {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
async execute(): Promise<ToolResult> {
|
||||
const result = await processSingleFileContent(
|
||||
this.params.absolute_path,
|
||||
|
||||
Reference in New Issue
Block a user