shell tool tweaks (#194)
This commit is contained in:
parent
a9dc2772dd
commit
a8f679ccb5
|
@ -1,8 +1,11 @@
|
|||
This is a minimal shell tool that executes a given command as `bash -c <command>`.
|
||||
This tool executes a given shell command as `bash -c <command>`.
|
||||
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.
|
||||
|
|
|
@ -43,12 +43,14 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
|
|||
|
||||
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<ShellToolParams, ToolResult> {
|
|||
return {
|
||||
llmContent: [
|
||||
`Command: ${params.command}`,
|
||||
`Directory: ${params.directory || '(root)'}`,
|
||||
`Stdout: ${stdout || '(empty)'}`,
|
||||
`Stderr: ${stderr || '(empty)'}`,
|
||||
`Error: ${error ?? '(none)'}`,
|
||||
|
|
Loading…
Reference in New Issue