summaryrefslogtreecommitdiff
path: root/packages/cli/src/tools/edit.tool.ts
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-04-18 13:37:51 -0400
committerN. Taylor Mullen <[email protected]>2025-04-18 14:02:09 -0400
commit7cd3b95317c4d9263e514f33589cb359766d463b (patch)
treeccca1f6d7e67e91c9a3603dd5251fa2c4c577274 /packages/cli/src/tools/edit.tool.ts
parent93fd6a9160d4654baf2f10269ce9689c553bb8cf (diff)
Fix linting errors in a number of core and tool files (partial)
- As part of this work I also started building out errors.ts which will be a cumulation of error helpers to better handle the challenging `catch (error: unknown)` requirement. - More changes are to come, this is truly a partial change in order to not disrupt as many people as possible. Part of https://b.corp.google.com/issues/411384603
Diffstat (limited to 'packages/cli/src/tools/edit.tool.ts')
-rw-r--r--packages/cli/src/tools/edit.tool.ts14
1 files changed, 5 insertions, 9 deletions
diff --git a/packages/cli/src/tools/edit.tool.ts b/packages/cli/src/tools/edit.tool.ts
index a98b9861..de8ccd5b 100644
--- a/packages/cli/src/tools/edit.tool.ts
+++ b/packages/cli/src/tools/edit.tool.ts
@@ -11,6 +11,7 @@ import {
import { makeRelative, shortenPath } from '../utils/paths.js';
import { ReadFileTool } from './read-file.tool.js';
import { WriteFileTool } from './write-file.tool.js';
+import { isNodeError } from '../utils/errors.js';
/**
* Parameters for the Edit tool
@@ -37,11 +38,6 @@ export interface EditToolParams {
expected_replacements?: number;
}
-/**
- * Result from the Edit tool
- */
-export interface EditToolResult extends ToolResult {}
-
interface CalculatedEdit {
currentContent: string | null;
newContent: string;
@@ -54,7 +50,7 @@ interface CalculatedEdit {
* Implementation of the Edit tool that modifies files.
* This tool maintains state for the "Always Edit" confirmation preference.
*/
-export class EditTool extends BaseTool<EditToolParams, EditToolResult> {
+export class EditTool extends BaseTool<EditToolParams, ToolResult> {
private shouldAlwaysEdit = false;
private readonly rootDirectory: string;
@@ -174,8 +170,8 @@ export class EditTool extends BaseTool<EditToolParams, EditToolResult> {
try {
currentContent = fs.readFileSync(params.file_path, 'utf8');
fileExists = true;
- } catch (err: any) {
- if (err.code !== 'ENOENT') {
+ } catch (err: unknown) {
+ if (!isNodeError(err) || err.code !== 'ENOENT') {
throw err;
}
fileExists = false;
@@ -300,7 +296,7 @@ export class EditTool extends BaseTool<EditToolParams, EditToolResult> {
* @param params Parameters for the edit operation
* @returns Result of the edit operation
*/
- async execute(params: EditToolParams): Promise<EditToolResult> {
+ async execute(params: EditToolParams): Promise<ToolResult> {
if (!this.validateParams(params)) {
return {
llmContent: 'Invalid parameters for file edit operation',