()
| 80 | } |
| 81 | |
| 82 | async function generateCli() { |
| 83 | const tools = createTools( |
| 84 | ServerConfig.applyDefaults( |
| 85 | {viaCli: true}, |
| 86 | {suppressUsageStatisticsNotice: true}, |
| 87 | ), |
| 88 | ); |
| 89 | |
| 90 | // Sort tools by name |
| 91 | const sortedTools = tools |
| 92 | .sort((a, b) => a.name.localeCompare(b.name)) |
| 93 | .filter(tool => { |
| 94 | // Skipping slim tools and tools behind internal flags. |
| 95 | if (isSlimTool(tool) || requiresHiddenFlag(tool)) { |
| 96 | return false; |
| 97 | } |
| 98 | // Skipping fill_form because it is not relevant in shell scripts |
| 99 | // and CLI does not handle array/JSON args well. |
| 100 | if (tool.name === 'fill_form') { |
| 101 | return false; |
| 102 | } |
| 103 | // Skipping wait_for because CLI does not handle array/JSON args well |
| 104 | // and shell scripts have many mechanisms for waiting. |
| 105 | if (tool.name === 'wait_for') { |
| 106 | return false; |
| 107 | } |
| 108 | // Skipping get_tab_id as it is for internal integrations |
| 109 | if (tool.name === 'get_tab_id') { |
| 110 | return false; |
| 111 | } |
| 112 | // Skipping in_page tools as they are not launched yet |
| 113 | if (tool.annotations.category === ToolCategory.IN_PAGE) { |
| 114 | return false; |
| 115 | } |
| 116 | return true; |
| 117 | }); |
| 118 | |
| 119 | const commands: Record< |
| 120 | string, |
| 121 | {description: string; category: string; args: Record<string, CliOption>} |
| 122 | > = {}; |
| 123 | |
| 124 | for (const tool of sortedTools) { |
| 125 | const inputSchema = zod.toJSONSchema(zod.object(tool.schema), { |
| 126 | io: 'input', |
| 127 | }) as JsonSchema; |
| 128 | const options = schemaToCLIOptions(tool.name, inputSchema); |
| 129 | const args: Record<string, CliOption> = {}; |
| 130 | for (const opt of options) { |
| 131 | args[opt.name] = opt; |
| 132 | } |
| 133 | |
| 134 | const categoryEnum = tool.annotations.category; |
| 135 | if (!categoryEnum) { |
| 136 | throw new Error(`Tool ${tool.name} has no category.`); |
| 137 | } |
| 138 | const category = labels[categoryEnum as unknown as keyof typeof labels]; |
| 139 | if (!tool.description) { |
no test coverage detected