From a8f679ccb55402215366cc86acfd5c221613b670 Mon Sep 17 00:00:00 2001 From: Olcan Date: Mon, 28 Apr 2025 08:17:52 -0700 Subject: [PATCH] shell tool tweaks (#194) --- packages/server/src/tools/shell.md | 7 +++++-- packages/server/src/tools/shell.ts | 13 ++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/server/src/tools/shell.md b/packages/server/src/tools/shell.md index 4427ef95..a8a42381 100644 --- a/packages/server/src/tools/shell.md +++ b/packages/server/src/tools/shell.md @@ -1,8 +1,11 @@ -This is a minimal shell tool that executes a given command as `bash -c `. +This tool executes a given shell command as `bash -c `. Command can be any valid single-line Bash command. +Command can start background processes using `&`. + The following information is returned: -Command: Given command. +Command: Executed command. +Directory: Directory (relative to project root) where command was executed, or `(root)`. Stdout: Output on stdout stream. Can be `(empty)` or partial on error. Stderr: Output on stderr stream. Can be `(empty)` or partial on error. Error: Error or `(none)` if no error occurred. diff --git a/packages/server/src/tools/shell.ts b/packages/server/src/tools/shell.ts index e80c0c02..8066044f 100644 --- a/packages/server/src/tools/shell.ts +++ b/packages/server/src/tools/shell.ts @@ -43,12 +43,14 @@ export class ShellTool extends BaseTool { getDescription(params: ShellToolParams): string { let description = `${params.command}`; - if (params.description) { - // replace any line breaks with spaces, in case instructions are not followed - description += ` (${params.description.replace(/\n/g, ' ')})`; - } + // append optional [./directory] if (params.directory) { - description += ` @ ${params.directory}`; + description += ` [./${params.directory}]`; + } + // append optional (description), replacing any line breaks with spaces + // tool description/schema should specify a single line w/o line breaks + if (params.description) { + description += ` (${params.description.replace(/\n/g, ' ')})`; } return description; } @@ -193,6 +195,7 @@ export class ShellTool extends BaseTool { return { llmContent: [ `Command: ${params.command}`, + `Directory: ${params.directory || '(root)'}`, `Stdout: ${stdout || '(empty)'}`, `Stderr: ${stderr || '(empty)'}`, `Error: ${error ?? '(none)'}`,