Modify shortenPath and add param validation (#663)

This commit is contained in:
anj-s
2025-06-03 08:59:17 -07:00
committed by GitHub
parent e9d43b9388
commit fffa06f0b1
2 changed files with 19 additions and 17 deletions

View File

@@ -364,16 +364,21 @@ Expectation for required parameters:
}
getDescription(params: EditToolParams): string {
if (!params.file_path || !params.old_string || !params.new_string) {
return `Model did not provide valid parameters for edit tool`;
}
const relativePath = makeRelative(params.file_path, this.rootDirectory);
if (params.old_string === '') {
return `Create ${shortenPath(relativePath)}`;
}
const oldStringSnippet =
params.old_string.split('\n')[0].substring(0, 30) +
(params.old_string.length > 30 ? '...' : '');
const newStringSnippet =
params.new_string.split('\n')[0].substring(0, 30) +
(params.new_string.length > 30 ? '...' : '');
return `${shortenPath(relativePath)}: ${oldStringSnippet} => ${newStringSnippet}`;
}