diff options
| author | Olcan <[email protected]> | 2025-04-29 15:31:46 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-29 22:31:46 +0000 |
| commit | c1b23c008a378c6c4b7f50fabc0ebf0280e0e5ad (patch) | |
| tree | 1eff904da3ac11a11a27ba6ed5dc1128a09647f5 /packages/server/src | |
| parent | e85db8aa3c2139beeee65a523083ec406450f47e (diff) | |
do not prepend ./ to absolute paths or . (#220)
Diffstat (limited to 'packages/server/src')
| -rw-r--r-- | packages/server/src/tools/shell.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/server/src/tools/shell.ts b/packages/server/src/tools/shell.ts index 1a5516ec..72672473 100644 --- a/packages/server/src/tools/shell.ts +++ b/packages/server/src/tools/shell.ts @@ -43,9 +43,14 @@ export class ShellTool extends BaseTool<ShellToolParams, ToolResult> { getDescription(params: ShellToolParams): string { 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) { - 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 // tool description/schema should specify a single line w/o line breaks |
