({
urlType,
repo,
}: RepoData)
| 967 | * @returns A descriptive string for the tool |
| 968 | */ |
| 969 | export function generateCodeSearchToolName({ |
| 970 | urlType, |
| 971 | repo, |
| 972 | }: RepoData): string { |
| 973 | try { |
| 974 | // Default tool name as fallback |
| 975 | let toolName = "search_code"; |
| 976 | if (urlType == "subdomain" || urlType == "github") { |
| 977 | // Use enforceLengthLimit to ensure the tool name doesn't exceed 55 characters |
| 978 | return enforceToolNameLengthLimit("search_", repo, "_code"); |
| 979 | } |
| 980 | // replace non-alphanumeric characters with underscores |
| 981 | return toolName.replace(/[^a-zA-Z0-9]/g, "_"); |
| 982 | } catch (error) { |
| 983 | console.error("Error generating code search tool name:", error); |
| 984 | // Return default tool name if there's any error parsing the URL |
| 985 | return "search_code"; |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | /** |
| 990 | * Generate a dynamic description for the code search tool based on the URL |
no test coverage detected