diff --git a/packages/cli/src/tools/glob.tool.ts b/packages/cli/src/tools/glob.tool.ts index d9d82210..4c23c3cb 100644 --- a/packages/cli/src/tools/glob.tool.ts +++ b/packages/cli/src/tools/glob.tool.ts @@ -92,7 +92,7 @@ export class GlobTool extends BaseTool { * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ - invalidParams(params: GlobToolParams): string | null { + validateToolParams(params: GlobToolParams): string | null { if ( this.schema.parameters && !SchemaValidator.validate( @@ -161,7 +161,7 @@ export class GlobTool extends BaseTool { * @returns Result of the glob search */ async execute(params: GlobToolParams): Promise { - const validationError = this.invalidParams(params); + const validationError = this.validateToolParams(params); if (validationError) { return { llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`, diff --git a/packages/cli/src/tools/grep.tool.ts b/packages/cli/src/tools/grep.tool.ts index 1c334a09..7dca170f 100644 --- a/packages/cli/src/tools/grep.tool.ts +++ b/packages/cli/src/tools/grep.tool.ts @@ -127,7 +127,7 @@ export class GrepTool extends BaseTool { * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ - invalidParams(params: GrepToolParams): string | null { + validateToolParams(params: GrepToolParams): string | null { if ( this.schema.parameters && !SchemaValidator.validate( @@ -161,7 +161,7 @@ export class GrepTool extends BaseTool { * @returns Result of the grep search */ async execute(params: GrepToolParams): Promise { - const validationError = this.invalidParams(params); + const validationError = this.validateToolParams(params); if (validationError) { console.error(`GrepTool Parameter Validation Failed: ${validationError}`); return { diff --git a/packages/cli/src/tools/ls.tool.ts b/packages/cli/src/tools/ls.tool.ts index fe18b9eb..82f4e913 100644 --- a/packages/cli/src/tools/ls.tool.ts +++ b/packages/cli/src/tools/ls.tool.ts @@ -135,9 +135,10 @@ export class LSTool extends BaseTool { * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ - invalidParams(params: LSToolParams): string | null { + validateToolParams(params: LSToolParams): string | null { if (this.schema.parameters && - !SchemaValidator.validate(this.schema.parameters as Record, params)) { + !SchemaValidator.validate(this.schema.parameters as Record, params) + ) { return 'Parameters failed schema validation.'; } if (!path.isAbsolute(params.path)) { @@ -199,7 +200,7 @@ export class LSTool extends BaseTool { * @returns Result of the LS operation */ async execute(params: LSToolParams): Promise { - const validationError = this.invalidParams(params); + const validationError = this.validateToolParams(params); if (validationError) { return this.errorResult( params, diff --git a/packages/cli/src/tools/read-file.tool.ts b/packages/cli/src/tools/read-file.tool.ts index 9737e75d..feb9cbae 100644 --- a/packages/cli/src/tools/read-file.tool.ts +++ b/packages/cli/src/tools/read-file.tool.ts @@ -106,7 +106,7 @@ export class ReadFileTool extends BaseTool< * @param params Parameters to validate * @returns True if parameters are valid, false otherwise */ - invalidParams(params: ReadFileToolParams): string | null { + validateToolParams(params: ReadFileToolParams): string | null { if ( this.schema.parameters && !SchemaValidator.validate( @@ -210,8 +210,7 @@ export class ReadFileTool extends BaseTool< * @returns Result with file contents */ async execute(params: ReadFileToolParams): Promise { - const validationError = this.invalidParams(params); - const filePath = params.file_path; + const validationError = this.validateToolParams(params); if (validationError) { return { llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`, @@ -219,6 +218,7 @@ export class ReadFileTool extends BaseTool< }; } + const filePath = params.file_path; try { if (!fs.existsSync(filePath)) { return { diff --git a/packages/cli/src/tools/terminal.tool.ts b/packages/cli/src/tools/terminal.tool.ts index 73f4af7d..6ec01427 100644 --- a/packages/cli/src/tools/terminal.tool.ts +++ b/packages/cli/src/tools/terminal.tool.ts @@ -317,7 +317,7 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es } // --- Parameter Validation (unchanged) --- - invalidParams(params: TerminalToolParams): string | null { + validateToolParams(params: TerminalToolParams): string | null { if ( !SchemaValidator.validate( this.parameterSchema as Record, @@ -400,7 +400,7 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es // --- Command Execution and Queueing (unchanged structure) --- async execute(params: TerminalToolParams): Promise { - const validationError = this.invalidParams(params); + const validationError = this.validateToolParams(params); if (validationError) { return { llmContent: `Command rejected: ${params.command}\nReason: ${validationError}`, diff --git a/packages/cli/src/tools/tools.ts b/packages/cli/src/tools/tools.ts index 9df90261..dcbd71ac 100644 --- a/packages/cli/src/tools/tools.ts +++ b/packages/cli/src/tools/tools.ts @@ -33,7 +33,7 @@ export interface Tool< * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ - invalidParams(params: TParams): string | null; + validateToolParams(params: TParams): string | null; /** * Gets a pre-execution description of the tool operation @@ -99,7 +99,7 @@ export abstract class BaseTool< * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ - invalidParams(params: TParams): string | null { + validateToolParams(params: TParams): string | null { // Implementation would typically use a JSON Schema validator // This is a placeholder that should be implemented by derived classes return null; diff --git a/packages/cli/src/tools/write-file.tool.ts b/packages/cli/src/tools/write-file.tool.ts index 1939bca0..c7dc8641 100644 --- a/packages/cli/src/tools/write-file.tool.ts +++ b/packages/cli/src/tools/write-file.tool.ts @@ -101,7 +101,7 @@ export class WriteFileTool extends BaseTool< * @param params Parameters to validate * @returns True if parameters are valid, false otherwise */ - invalidParams(params: WriteFileToolParams): string | null { + validateToolParams(params: WriteFileToolParams): string | null { if ( this.schema.parameters && !SchemaValidator.validate( @@ -185,7 +185,7 @@ export class WriteFileTool extends BaseTool< * @returns Result of the file writing operation */ async execute(params: WriteFileToolParams): Promise { - const validationError = this.invalidParams(params); + const validationError = this.validateToolParams(params); if (validationError) { return { llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,