summaryrefslogtreecommitdiff
path: root/packages/cli/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/tools')
-rw-r--r--packages/cli/src/tools/ls.tool.ts23
-rw-r--r--packages/cli/src/tools/read-file.tool.ts5
-rw-r--r--packages/cli/src/tools/terminal.tool.ts18
-rw-r--r--packages/cli/src/tools/web-fetch.tool.ts6
-rw-r--r--packages/cli/src/tools/write-file.tool.ts5
5 files changed, 24 insertions, 33 deletions
diff --git a/packages/cli/src/tools/ls.tool.ts b/packages/cli/src/tools/ls.tool.ts
index d2f6a3c7..4b015fa5 100644
--- a/packages/cli/src/tools/ls.tool.ts
+++ b/packages/cli/src/tools/ls.tool.ts
@@ -116,8 +116,12 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> {
* @returns An error message string if invalid, null otherwise
*/
validateToolParams(params: LSToolParams): string | null {
- if (this.schema.parameters &&
- !SchemaValidator.validate(this.schema.parameters as Record<string, unknown>, params)
+ if (
+ this.schema.parameters &&
+ !SchemaValidator.validate(
+ this.schema.parameters as Record<string, unknown>,
+ params,
+ )
) {
return 'Parameters failed schema validation.';
}
@@ -181,7 +185,8 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> {
if (validationError) {
return this.errorResult(
`Error: Invalid parameters provided. Reason: ${validationError}`,
- `Failed to execute tool.`);
+ `Failed to execute tool.`,
+ );
}
try {
@@ -189,12 +194,14 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> {
if (!stats) {
return this.errorResult(
`Directory does not exist: ${params.path}`,
- `Directory does not exist.`);
+ `Directory does not exist.`,
+ );
}
if (!stats.isDirectory()) {
return this.errorResult(
`Path is not a directory: ${params.path}`,
- `Path is not a directory.`);
+ `Path is not a directory.`,
+ );
}
const files = fs.readdirSync(params.path);
@@ -202,7 +209,8 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> {
if (files.length === 0) {
return this.errorResult(
`Directory is empty: ${params.path}`,
- `Directory is empty.`);
+ `Directory is empty.`,
+ );
}
for (const file of files) {
@@ -249,7 +257,8 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> {
} catch (error) {
return this.errorResult(
`Error listing directory: ${error instanceof Error ? error.message : String(error)}`,
- 'Failed to list directory.');
+ 'Failed to list directory.',
+ );
}
}
}
diff --git a/packages/cli/src/tools/read-file.tool.ts b/packages/cli/src/tools/read-file.tool.ts
index feb9cbae..9bc10491 100644
--- a/packages/cli/src/tools/read-file.tool.ts
+++ b/packages/cli/src/tools/read-file.tool.ts
@@ -27,10 +27,7 @@ export interface ReadFileToolParams {
/**
* Implementation of the ReadFile tool that reads files from the filesystem
*/
-export class ReadFileTool extends BaseTool<
- ReadFileToolParams,
- ToolResult
-> {
+export class ReadFileTool extends BaseTool<ReadFileToolParams, ToolResult> {
static readonly Name: string = 'read_file';
// Maximum number of lines to read by default
diff --git a/packages/cli/src/tools/terminal.tool.ts b/packages/cli/src/tools/terminal.tool.ts
index 1049a224..dacfb0be 100644
--- a/packages/cli/src/tools/terminal.tool.ts
+++ b/packages/cli/src/tools/terminal.tool.ts
@@ -115,10 +115,7 @@ interface QueuedCommand {
/**
* Implementation of the terminal tool that executes shell commands within a persistent session.
*/
-export class TerminalTool extends BaseTool<
- TerminalToolParams,
- ToolResult
-> {
+export class TerminalTool extends BaseTool<TerminalToolParams, ToolResult> {
static Name: string = 'execute_bash_command';
private readonly rootDirectory: string;
@@ -134,10 +131,7 @@ export class TerminalTool extends BaseTool<
private rejectShellReady: ((reason?: unknown) => void) | undefined; // Definite assignment assertion
private readonly backgroundTerminalAnalyzer: BackgroundTerminalAnalyzer;
- constructor(
- rootDirectory: string,
- outputLimit: number = MAX_OUTPUT_LENGTH,
- ) {
+ constructor(rootDirectory: string, outputLimit: number = MAX_OUTPUT_LENGTH) {
const toolDisplayName = 'Terminal';
// --- LLM-Facing Description ---
// Updated description for background tasks to mention polling and LLM analysis
@@ -454,9 +448,7 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es
// Define temp file paths here to be accessible throughout
let tempStdoutPath: string | null = null;
let tempStderrPath: string | null = null;
- let originalResolve: (
- value: ToolResult | PromiseLike<ToolResult>,
- ) => void; // To pass to polling
+ let originalResolve: (value: ToolResult | PromiseLike<ToolResult>) => void; // To pass to polling
let originalReject: (reason?: unknown) => void;
const promise = new Promise<ToolResult>((resolve, reject) => {
@@ -939,9 +931,7 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es
initialStderr: string, // Stderr during launch phase
tempStdoutPath: string, // Path to redirected stdout
tempStderrPath: string, // Path to redirected stderr
- resolve: (
- value: ToolResult | PromiseLike<ToolResult>,
- ) => void, // The original promise's resolve
+ resolve: (value: ToolResult | PromiseLike<ToolResult>) => void, // The original promise's resolve
): Promise<void> {
// This function manages its own lifecycle but resolves the outer promise
let finalStdout = '';
diff --git a/packages/cli/src/tools/web-fetch.tool.ts b/packages/cli/src/tools/web-fetch.tool.ts
index 74467605..4fc1e45e 100644
--- a/packages/cli/src/tools/web-fetch.tool.ts
+++ b/packages/cli/src/tools/web-fetch.tool.ts
@@ -90,9 +90,7 @@ export class WebFetchTool extends BaseTool<
getDescription(params: WebFetchToolParams): string {
// Shorten long URLs for display
const displayUrl =
- params.url.length > 80
- ? params.url.substring(0, 77) + '...'
- : params.url;
+ params.url.length > 80 ? params.url.substring(0, 77) + '...' : params.url;
return `Fetching content from ${displayUrl}`;
}
@@ -130,7 +128,7 @@ export class WebFetchTool extends BaseTool<
headers: {
'User-Agent': 'GeminiCode-CLI/1.0',
},
- signal: AbortSignal.timeout(15000) // 15 seconds timeout
+ signal: AbortSignal.timeout(15000), // 15 seconds timeout
});
if (!response.ok) {
diff --git a/packages/cli/src/tools/write-file.tool.ts b/packages/cli/src/tools/write-file.tool.ts
index cc0d5511..af0adc8d 100644
--- a/packages/cli/src/tools/write-file.tool.ts
+++ b/packages/cli/src/tools/write-file.tool.ts
@@ -28,10 +28,7 @@ export interface WriteFileToolParams {
/**
* Implementation of the WriteFile tool that writes files to the filesystem
*/
-export class WriteFileTool extends BaseTool<
- WriteFileToolParams,
- ToolResult
-> {
+export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
static readonly Name: string = 'write_file';
private shouldAlwaysWrite = false;