do not prepend ./ to absolute paths or . (#220)

This commit is contained in:
Olcan 2025-04-29 15:31:46 -07:00 committed by GitHub
parent e85db8aa3c
commit c1b23c008a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -43,9 +43,14 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> {
getDescription(params: ShellToolParams): string { getDescription(params: ShellToolParams): string {
let description = `${params.command}`; let description = `${params.command}`;
// append optional [./directory], prepending ./ if missing (assuming relative per validation) // append optional [./directory], prepending ./ if missing and relative
// note description is needed even if validation fails due to absolute path
if (params.directory) { if (params.directory) {
description += ` [${params.directory.startsWith('./') ? '' : './'}${params.directory}]`; let path = params.directory;
if (!path.startsWith('./') && !path.startsWith('/') && path !== '.') {
path = './' + path;
}
description += ` [${path}]`;
} }
// append optional (description), replacing any line breaks with spaces // append optional (description), replacing any line breaks with spaces
// tool description/schema should specify a single line w/o line breaks // tool description/schema should specify a single line w/o line breaks